Originally posted by Steve McCain:
Hi,
I can check in my servlet code whether a user currently
has a valid session. If there is not a valid session
is it possible to detect whether the user's session has been timed-out by WAS rather than the user never having had a session?
In some of my servlets I test for a valid seesion & forward
to the login page if necessary, I want to give a nice
message if the user has to login again if the session has timed out.
thanks
Steve McCain
All you have to do to check for a valid session is use
HttpSession mySession = req.getSession(false);
if (mySession == null)
// redirect to login page
else
// do what you normally intended....
There is no way of finding out if a session timed out vs. the user never had one. However, you can be notified asynchronously when a session does time out by adding an object of type HttpSessionBindingListener to the HttpSession when it is created. See the spec for details.
Kyle
------------------
Kyle Brown,
Author of
Enterprise Java (tm) Programming with IBM Websphere
See my homepage at
http://members.aol.com/kgb1001001 for other WebSphere information.