HttpSession: I have ONE instance of the browser creating TWO different sessions!!!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pedro_Gaspar
Posted On:   Wednesday, July 10, 2002 04:08 AM

I'm running into some odd problems with session objects. My webapp uses a session object to store some information, namely, the screen size, the language and a user parameter that indicates if he or she has already logged in. All my servlets create a session object to check for this information and act accordingly to it. They also check if the session is new or if it has already been created, through the isNew() method. The problem is that this method keeps returning 'true' even for sessions already created (I've checked this by comparing the sessions id's). As a result, I end up with two different sessions created by a single instance of my browser, witch I thought to be impossible. The first session is creat   More>>

I'm running into some odd problems with session objects.



My webapp uses a session object to store some information, namely, the screen size, the language and a user parameter that indicates if he or she has already logged in.



All my servlets create a session object to check for this information and act accordingly to it.


They also check if the session is new or if it has already been created, through the isNew() method.



The problem is that this method keeps returning 'true' even for sessions already created (I've checked this by comparing the sessions id's).


As a result, I end up with two different sessions created by a single instance of my browser, witch I thought to be impossible.


The first session is created by my IndexServlet that redirects the browser to the LoginServlet. This servlet should create a handle to the session created by IndexServlet by invoking the getSession() method of the request object but it creates a new one!!



I've checked the API for the isNew() method and it says the following:


Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.



Now, what does this mean? How do I enforce the client to know about a session?



Thank you!



Best regards from Portugal


   <<Less

Re: HttpSession: I have ONE instance of the browser creating TWO different sessions!!!

Posted By:   Gautam_Marwaha  
Posted On:   Wednesday, July 10, 2002 05:49 AM

ideally getSession() shd return you an existing session, if already created OR create a new one.


which web container are you using?
About | Sitemap | Contact