File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes sessionid() returning different values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "sessionid() returning different values" Watch "sessionid() returning different values" New topic
Author

sessionid() returning different values

chandana nannapaneni
Ranch Hand

Joined: Dec 18, 2008
Posts: 39
Hi,

I have 2 servlets "servletA" and "servletB". there are 2 jsp pages "page1.jsp" and "page2.jsp".
when a user clicks a button on page1.jsp, servletA is executed, and then user is redirected to page2.jsp.
On page2.jsp, there is another button which corresponds to servletB. Now I need to set an atrribute in servletA and access the value of that in servletB.

So, I used session.setAttribute("att","abc") in servletA.
Now I retrieve the value of att in servletB as (String)session.getAttribute("att").

Now the problem is that,
When I run the webapplication it almost works well.
But occasionally, (String)session.getAttribute("att") is returning NULL. This happens 2 times out of 10 times.
I tried to print the session.Id values in both servlets, both are returning different values when this error occurs.

A single user will have only one session. But why am I getting different session.Id occasionally?
Can anyone help me with this?



Chandana.
Mathieu Poitras
Greenhorn

Joined: Aug 22, 2008
Posts: 3
Maybe the host is not the same in between request?

I believe that http://localhost:8080 will have a different session than http://127.0.0.1:8080.

Also, I also think that a different browser will have a different session. Thus if you make some calls through Firefox and some others with Interner Explorer, the session might not be the same.

Maybe you could check if the cookie in the browser is different in your calls that fails.
chandana nannapaneni
Ranch Hand

Joined: Dec 18, 2008
Posts: 39
Thanks Mathieu. Your views were helpful.
 
Don't get me started about those stupid light bulbs.
 
subject: sessionid() returning different values