File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes 2 approaches to set session timeout?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "2 approaches to set session timeout??" Watch "2 approaches to set session timeout??" New topic

2 approaches to set session timeout??

Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
Hello all,
I have deployed my servlets in JBOSS server.
By default it takes 30 mins as session timeout.
There are 2 approaches for this:

1. The HttpSession object has setMaxInactiveInterval() method which can be used to control the session.
2. Also i have heard that i can configure the web.xml for this session timeout value.
Am i right about this?
Among these 2 approaches which is a better one?
Sajee Joseph
john smith
Ranch Hand

Joined: Mar 04, 2004
Posts: 75
Keeping config stuff in web.xml is always preferable. You don't have to rewrite code to reconfigure your app, and you know there is only one source for config values.
[ March 10, 2004: Message edited by: john smith ]
Brian Showalter

Joined: Sep 20, 2002
Posts: 3
On our in-house intranet, I like to set a short (10 minutes) default session timeout in the web.xml, and when users log in the timeout is increased to one hour. Since most users are primarily interested in viewing openly accessible information which does not require a login, this helps to keep sessions from consuming resources unnecessarily.
It is sorta covered in the JavaRanch Style Guide.
subject: 2 approaches to set session timeout??
It's not a secret anymore!