Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1511
  • Last Modified:

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.

0
jwright9
Asked:
jwright9
1 Solution
 
HonorGodCommented:
To what tag did you add the session-config clause?

You should be able to do it using the JMX API.
0
 
Gibu GeorgeCTOCommented:
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
 
prototypeitCommented:
I would use session.setMaxInactiveInterval(ONE_HOUR);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now