• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
RabiDas Sharma
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic