How do I use servlet filter to check session time-out? Is there an example I can take a look at? Thank you very much.
Right now, I check session time-out in each of my servlet. People are saying that servlet filter can be used to check session time-out with all JSPs and servlets remain intact.
How do I use servlet filter to check session time-out? Is there an example I can take a look at?
Hmm. I am having trouble understanding exactly what you are trying to do. Could you be a bit more specific about what you are trying to accomplish? Maybe you can give a tiny code snippet of what you are already doing so we can see whether/how it could be done in a filter?
Originally posted by Pradeep Bhat:
The Java pet store uses Filter for prototected pages which requires user to log in. May be you can have a look aty it.
I think the simple answer to the question would be to call the setMaxInactiveInterval method to control timeout. The example is not enough by itself to answer the original question. The session that JSP "sees" is controlled by the servlet as determined by the MaxInactive Interval setting. This is described in http://java.sun.com/webservices/docs/1.2/api/javax/servlet/http/HttpSession.html for details.
Originally posted by JiaPei Jen:
[QB]I have lots of servlets in my application. Right now, I am checking if the session has timed out in each of my servlet.
I guess u have developed a pretty poorly designed web app. It will make u more busy on checking the session in each of your servlets...
But I have something for you here... In the following link, which I got from Sun's Enterprise Java Technologies Tech Tips Newsletter every month, it talks about the servlet filter and I do hope that it is suitable for your web app in the current situation... Here it is...