Setting session timeout dynamically in Java code

Is there a way to programatically to set the session timeout in Websphere 6.1 using Java in a J2EE application?

I was able to reset the time out by adding:

<session-config>
<session-timeout>2</session-timeout>
</session-config>

to the web.xml file.

jwright9Asked:
Who is Participating?
 
Gibu GeorgeConnect With a Mentor CTOCommented:
There is a method getLastAccessedTime() which can be used to check the time the session had been inactive and be invalidated

long inactiveTimeInMillis=System.currentTimeInMillies()-session.getLastAccessedTime();
if(inactiveTimeInMillis > <a specified time>)
  session.invalidate()
0
 
HonorGodCommented:
To what tag did you add the session-config clause?

You should be able to do it using the JMX API.
0
 
prototypeitCommented:
I would use session.setMaxInactiveInterval(ONE_HOUR);
0
All Courses

From novice to tech pro — start learning today.