File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Apporpriate place for session.setMaxInactiveInterval(20) when I have bunch of servlets and jsps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Apporpriate place for session.setMaxInactiveInterval(20) when I have bunch of servlets and jsps" Watch "Apporpriate place for session.setMaxInactiveInterval(20) when I have bunch of servlets and jsps" New topic
Author

Apporpriate place for session.setMaxInactiveInterval(20) when I have bunch of servlets and jsps

RabiDas Sharma
Ranch Hand

Joined: Nov 18, 2013
Posts: 69
Hi everyone,
I'm using session.setMaxInactiveInterval(20) in order to set session time.

I'm using this in any of the jsp page or servlet of my web app to set session time and it is
working fine i.e, session is getting expired in other web pages also after 20sec

please tell me which is the appropriate place for session.setMaxInactiveInterval(20) if i'm
having 3-4 servlets and 6-7 jsps.

I guess 1sp jsp page requested(home page) should have this statement??
please correct me..

And also please tell me If I don't use filter for this purpose what will be the problem?


thanks in advance
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Yes, using a filter would make the most sense. When you find yourself repeating code in every servlet, then you should think of using a filter for that code.

Alternatively if you have code which specifically creates the session, such as a login page, then you could set the maxInactiveInterval at that time. But there's no harm in setting it more than once.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apporpriate place for session.setMaxInactiveInterval(20) when I have bunch of servlets and jsps