File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes session-config in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session-config in web.xml" Watch "session-config in web.xml" New topic

session-config in web.xml

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 241
hi guys

i know that we have to use this stuff for maintaining session in a web application in web.xml


i want to know what will happen if didnt configure this element in the web.xml is that container will provide any default values for this, also i want know the different behavior when this element is not set in web.xml

but iam able to deploy the application without this element in the web.xml
with jboss 4.0

looking for your replies
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

The Servlet Specification(2.4) tells :
If this element is not specified, the container must set its default timeout period.. Refer to it whenever you have such a doubt.

[My Blog]
All roads lead to JavaRanch
sanjiv tuli

Joined: Apr 05, 2010
Posts: 3
Setting session timeout through the deployment descriptor should work - it sets the default session timeout for the web app. Calling session.setMaxInactiveInterval() sets the timeout for the particular session it is called on, and overrides the default. Be aware of the unit difference, too - the deployment descriptor version uses minutes, and session.setMaxInactiveInterval() uses seconds.


sets the default session timeout to 60 minutes.


sets the session timeout to 600 seconds - 10 minutes - for the specific session it's called on.

This should work in Tomcat or Glassfish or any other Java web server - it's part of the spec.
I agree. Here's the link:
subject: session-config in web.xml
It's not a secret anymore!