You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lionel Farbos <li...@free.fr> on 2005/04/01 12:30:58 UTC

Re: session management

On Thu, 31 Mar 2005 11:41:55 -0800 (PST)
Jagadeesha T <ja...@yahoo.com> wrote:

> Hi all,
>         I want to set session in httpservletresponse object, Is there 
> any way to do it.
>  Otherthan response.addCookie(), or 
>                 response.encodeURL();
> Is there any way to set the Jsession In headers, So that it gets that 
> in the next Jsp by request object, 
> If I use addCookie of response object, It fails if any where encodeURL 
> is used. 
> If i user encodeURL, every JSP needs to updated with that method.
> Please if anybody knows tell the way that can be done. 
>
You don't have to create yourself the cookie.
You create the HttpSession with HttpServletRequest.getSession() or HttpServletRequest.getSession(boolean)
Then, the session is created and the cookie JSESSIONID is added to the HttpServletResponse.
So, the next time you'll invoke a servlet or JSP in the same Context (with the same browser),
the Cookie JSESSIONID will be attached to your request.

If you have clustered your Tomcat, the JSESSIONID will have a suffix .<jvmRoute>,
so, if you use the mod_jk to load-balance your tomcat clustered servers, 
your request will be sent to the same tomcat (as the precedent).

Enjoy

> Thanks,
> Jagadeesha T
> 
> 
> 		
> ---------------------------------
> Do you Yahoo!?
>  Better first dates. More second dates. Yahoo! Personals 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org