• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sessionid() returning different values

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mathieu. Your views were helpful.
reply
    Bookmark Topic Watch Topic
  • New Topic