File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes increase session life time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "increase session life time" Watch "increase session life time" New topic

increase session life time

joseph prabhu
Ranch Hand

Joined: Feb 26, 2008
Posts: 162
In my jsp project session is being expired in 20 minutes(default).

how can i increse the session life time. where i have to write that code
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Hi Prabhu,

You can set the session timeout manually using the session.setMaxInactiveInterval(<seconds>);

For more info, check the below link.

Johnson Abraham

Joined: May 31, 2004
Posts: 19
You can define the session time out in your applications web.xml in the following tag


The value for the session-timeout tag is in minutes. The above declaration will make your session time-out to 30 minutes.

If you want to maintain the session time-out in the code itself you can do so this way

The value
provided int he above piece of code is in seconds

you can also set the above value to
so that session never expires
Karthikeyan Ramaswamy
Ranch Hand

Joined: Apr 30, 2008
Posts: 42

you can increase session time-out in 2 way,

1.Use setMaxInactiveInterval(int interval) method of the HttpSession.

2.Use web.xml, <session-timeout>20</session-timeout> Tag

setMaxInactiveInterval() takes in seconds.

web.xml effects whole web application (takes in mintutes).
I agree. Here's the link:
subject: increase session life time
It's not a secret anymore!