matthew016
asked on
Session expired
Hi,
When a session expires,
I want to display an alert message "Session Expired" (or maybe you have a better idea ?)
And then forward the user to the main page.
The problem is that in my code I don't know how I can check if a session expired.
For example he stays on the same page during mre than 30 minutes, then he clicks on a button calling some action, there will be errors because I am trying to read information in the session.
Thank you for any help.
When a session expires,
I want to display an alert message "Session Expired" (or maybe you have a better idea ?)
And then forward the user to the main page.
The problem is that in my code I don't know how I can check if a session expired.
For example he stays on the same page during mre than 30 minutes, then he clicks on a button calling some action, there will be errors because I am trying to read information in the session.
Thank you for any help.
ASKER
The problem is in the code,
it will have exceptions at runtime.
it will have exceptions at runtime.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also use a listener HttpSessionListener
it has two methods
sessionCreated(HttpSession Event e)
and
sessionDestroyed(HttpSessi onEvent e)
so just before a session is going to destroy you can set an attribute in servlet context
it has two methods
sessionCreated(HttpSession
and
sessionDestroyed(HttpSessi
so just before a session is going to destroy you can set an attribute in servlet context
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The only good suggestion is the filter,
but I assist others for the effort of course
but I assist others for the effort of course
function alertSessionTimeout() {
var delayInSeconds = <%=session.getMaxInactiveI
var delay = delayInSeconds * 1000;
self.setTimeout('showSessi
}
function showSessionAlert() {
var msg = 'Session Expired'
alert(msg);
self.location = '/';
}