You need to do a session check before anything else for every request. This could be done, for example, with a filter (see javax.servlet.Filter) or by having each servlet to inherit from some kind of "SessionValidatorServlet", which redirects requests without a session to the login page.
You can implement the HttpSessionListener interface. The sessionDestroyed method is called when the session is invalidated.
Joined: Mar 09, 2001
Originally posted by Matthew Phillips: Your filter can implement the HttpSessionListener interface. The sessionDestroyed method is called when the session is invalidated.
Joined: Apr 25, 2003
Sorry, I wasn't specific enough. I am using struts and I would like to automatically forward to some notification page when the session expires; but I want this to happen without user intervention. For example, a user leaves a browser unattended for 30 min & session timeout is 30 min; I would want the page to automatically forward to another page without the user submitting the page.
Joined: Jan 23, 2002
How about putting a refresh interval into the HTML HEAD section of the page to "poll" session timeout?
hi, I think that your timer might be on the client. JSP couldn`t do so much in that case. I little bit ago, I really need to use that but my application runs over an intranet and all the browsers are IE, so the problem reduces to use this VB Script 'Object to hold the timer Dim idTimer 'time of life of the session Dim sessionTimeOut function startTimer(vTime) if time <> "" then sessionTimeOut=vTime else vTime=sessionTimeOut end if idTimer = setTimeout ("goOut()", vTime) end function function goOut() location.href="miUrl" end function function resetTimeOut() clearTimer idTimer startTimer "" end function I hope that this help.