• Post Reply Bookmark Topic Watch Topic
  • New Topic

session.getAttribute  RSS feed

 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I having a problem in using session.getAttribute(). I am setting a session attribute in a servlet using HttpSession.setAttribute(). The servlet is called from an applet. When the servlet is again called after a time interval of 30 minutes, the attribute is lost i.e. session.getAttribute("attributename") returns null. Does an HTTPSession get refreshed after a time interval and where is the time interval specified. Can anybody help me in this regard. Any help will be appreciated.

Regards
Abhijit.
 
Darren Edwards
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions have a default timeout period which can be changed in web.xml



20 - 30 is probably about the default for the container you are using, which explains the behaviour you described.
 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the response.
However i found that the attribute in session is lost even before the interval specified in web.xml. Actually i am loading an applet from jsp using JspWriter.printlns(<APPLET...> . before loading the applet i am setting the session attribute. The APPLET is triggering servlets, however the attribute is not visible to servlets even after 5 minutes. Can any body help me.

Regards
Abhijit
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One possibility is that your servlet code is not checking for an existing session but always creates a new one.
Another possibility is that the applet does not properly use the session ID c o o k i e when addressing the servlet so the original session is never found. You might look into passing the session ID to the applet so that it can URLEncode the id in the request.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!