Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sessionid() returning different values

 
chandana nannapaneni
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


 
Mathieu Poitras
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mathieu. Your views were helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic