You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Kumar, Kiran" <kk...@kheaa.com> on 2005/04/17 03:45:31 UTC

RE: [Authentication] - User with mixed Sessions

Thanks for all the information. here is what I started doing after some
research

To Start with here is the changes I did

1. stopped storing document in session. only root element is stored

2. here is the sample sitemap pipeline. I will give you complete sitemap
when I go to office tomorrow morning
 
when there xml needs to be built
<map:match .....>
   <map:act type="xml">
    <map:generate type="session-attr">
      <map:parameter name="attr-name" value="root"/>
     </map:generate> 
    <map:transform...../>
   </map:act>
</map:match>
  

when not required
<map:match .....>
    <map:generate type="session-attr">
      <map:parameter name="attr-name" value="root"/>
     </map:generate> 
    <map:transform...../>
</map:match>

3. To remove the caching problem, I started using a Filter and in the
doFilter() method, I am setting the response.setHeader("Cache-control","
no-cache") etc

This filters all the requests coming to the web.xml

4. in the <map:handle-errors/> pipeline in subsitemap, rebuilding the xml
when user requests a URL from their bookmarks

--------------------------------------

also I will follow the session creation rules..


but I am still not clear how to control the multithreading issue?????


please guide me in this







-----Original Message-----
From: Antonio Gallardo
To: Kumar, Kiran
Sent: 4/16/2005 9:32 PM
Subject: RE: [Authentication] - User with mixed Sessions

On Sab, 16 de Abril de 2005, 13:22, Kumar, Kiran dijo:
> HI Antonio,

hi,

> greetings and thanks for quick response.
>
> this is  a production problem I am working on.  and I need to fix this
> ASAP.
>
> we have a website with thousands of users logging in to check their
> account
> information.
>
> we are using Cocoon 2.1 version. we

Is posible to update to a newer version? Perhaps after 2.1.5.1?

> also tried no-cache on all the stylesheets. It did not work and
according
> to
> the Web-Team this is taking longer time to load the pages with lots of
> images.

I will like to see the sitemaps? And some generated pages.

> we had synchronized the code which creates the xml DOM objects using
> here is the action templates we use
>
> ----------------------------------------------------------------------
> this is the first action which creates the documents.
> ++++++++++++++++++++++++++++++++++
> public class XmlAction extends AbstractAction implements
SingleThreaded {
>
> 	/**
> 	 * @see org.apache.cocoon.acting.Action#act(Redirector,
> SourceResolver, Map, String, Parameters)
> 	 */
> 	public Map act(Redirector redirector,SourceResolver resolver,Map
> objectModel
> 			,String source,Parameters parm)
> 		throws Exception
> 	{
>
> 		Map map = new HashMap();
> 		Request request =
ObjectModelHelper.getRequest(objectModel);
> 		Session session = request.getSession(true);

Try to use request.getSession(true) only in places where you are sure
the
user needs to create a new session. I remember to had problems with
that.
The same apply to the action below. Try to make a map where the use is
going and use request.getSession(false) where you are sure the user
already has a session.

> 		DocumentBuilderFactory dbf =
> DocumentBuilderFactory.newInstance();
>
> 		synchronized(dbf) {
> 			doc = dbf.newDocumentBuilder().newDocument();
> 		}
> 		session.setAttribute("myAttribute", doc);
> 		session.setAttribute("root", sroot);
> 		session.setAttribute("student",student);
> 	return map;
> 	}
> }
>
------------------------------------------------------------------------
>
>
>  other actions use this session document to append/remove the elements
>
>
> +++++++++++++++++++++++++
> public class OtherAction extends AbstractAction implements ThreadSafe
{
>
> 	/**
> 	 * @see org.apache.cocoon.acting.Action#act(Redirector,
> SourceResolver, Map, String, Parameters)
> 	 */
> 	public Map act(Redirector redirector,SourceResolver resolver,Map
> objectModel
> 			,String source,Parameters parm)
> 		throws Exception
> 	{
>
> 		Map map = new HashMap();
> 		Request request =
ObjectModelHelper.getRequest(objectModel);
> 		Session session = request.getSession(true);
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
                                  ||||||||||||||||||||||||

Same as above.

> 		doc = (Document)session.getAttribute("myAttribute");
>
> 		----
> 		----
> 		----
>
> 		session.setAttribute("myAttribute", doc);
> 		session.setAttribute("root", sroot);
> 		session.setAttribute("student",student);
> 	return map;
> 	}
> }
>
> -------
>
> All the actions follow the same structure

Are you tried to debug this part of the code? You can use eclipse to see
"step by step" what is going on and keep track of the variables you
think
are causing troubles.

Best Regards,

Antonio Gallardo