This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

increase session life time

 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prabhu,

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

For more info, check the below link.

http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpSession.html#setMaxInactiveInterval(int)

Regards,
Kiran.
 
Johnson Abraham
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can define the session time out in your applications web.xml in the following tag

</web-app>

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
36000
provided int he above piece of code is in seconds

you can also set the above value to
-1
so that session never expires
 
Karthikeyan Ramaswamy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic