tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jagadeesha T <jagga_stud...@yahoo.com>
Subject Re: session management
Date Sat, 02 Apr 2005 20:07:26 GMT
Hi, Thanks the reply,
 My requirement is little different.
I want to have many browser instaces (2 or more)to use the same session.
In my first.jsp, on first hit, i will get the session and store it.
Again,if the first jsp is hit for the second time. It should use the
same session. SO, I will not let it allow to create a new one. Instead use the one already
stored for user.
I have to do like this since the user login is done from a Java Applacition(Swing).
If the user wants to go to a browser. User has to click on the button (Swing UI) that will
launch the 
browser. each click on the button should launch a browser.
I want all those browsers launched for that login to use a shared session object.
Could you tell How can I do it.
I tried by setting the cookie at the first.jsp when the second browser launch(Coolke which
had created at the 
first
hit).
addCookie,
      In one of the middle jsps, there is 
      response.sendRedirect(response.encodeURL("samepage?somename=somevalue"))
             Every time,    it is failing here, response.sendRedirect();
 //When it is reloaded i have observerd that it is not getting the cookie in the headers.
 I don't understand why the browser not sending the cookie. cookie is not disabled.
 
Scenario 2.
If all browser uses different session objects. then it works fine.
 
could you tell me is there any way to get this done?
Thanks,
Jagadish


 

Lionel Farbos <lionel.farbos@free.fr> wrote:
On Thu, 31 Mar 2005 11:41:55 -0800 (PST)
Jagadeesha T 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 .,
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


		
---------------------------------
Do you Yahoo!?
 Better first dates. More second dates. Yahoo! Personals 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message