Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

sessionid() returning different values  RSS feed

 
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?


 
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
Boost this thread!