-
Session Timeouut
hello Sir, I have to make a web application in which i have to give session timeout .
means if screen is inactive for a particular period of time then automatically it should
redirect to login page from where user has to login again to access the resources.
I know filters are used for this but do not have the idea .
will you plz give me the example for this task .
will always be gratefull.
-
Re: Session Timeouut
Hi ,
You can use filter for same and other option is try to read sessiontimeout from request scope and compare from your maximum session interval.
Right some condtion there and if its is max then session interval , redirect on login page.
-
Re: Session Timeouut
First you need to write down the following piece of code in web.xml :
<session-config>
<session-timeout>15</session-timeout>
</session-config>
Here we have set the session time out = 15 minute for the web application.
Now you have to add following piece of code in all the servlets.
HttpSession session = request.getSession(false); //return only the active sessin object
if (session == null)
{
//redirect to login page
}
But this is a long way to implement the functionality.
I will suggest you to use the filter for the same.
cheers
sharad
-
Re: Session Timeouut
yes, I have used the code which is posted by u. But i want to redirect automatically. In my code redirecting is working, But i should refresh the browser.
-
Re: Session Timeouut
Please do not report your own post as spam in an effort to receive more attention. You have now spammed every moderator of the forum with a report email, which actually decreases your chances of getting help.
It's only been a few hours. Be patient and give it a few hours, or better yet, ask a more specific question, let us know what you've done already, and we'll go from there. Notice that this forum is title "What's Wrong with My Code?" yet you have not posted any code.