This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Servlets and the fly likes state of session object after timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "state of session object after timeout" Watch "state of session object after timeout" New topic
Author

state of session object after timeout

Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
Hi,
could someone please let me know, what would be state of the session object once it is timed out.
Will it be null?
If I do operation session.getAttribute("KEY"), what I'll get if this is done on the timed out session.
Thanks
Sanjeev Kaushik


Sanjeev Kaushik
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8920

Yes it will be null.


Groovy
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
From the exception I am getting, I understand that session object is not null. If I get something out of session, that is returned null.
Can someone verify.
Sanjeev Kaushik
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8920

If session times out and you call
1 .request.getSession() or request.getSession(true) a new session will returned
2. request.getSession(false) will try to get old session .The old session has timed out so the return value will be null.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: state of session object after timeout