Solved

Setting session timeout dynamically in Java code

Posted on 2009-04-10
3
1,504 Views
Last Modified: 2013-12-11
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
Comment
Question by:jwright9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 24138204
To what tag did you add the session-config clause?

You should be able to do it using the JMX API.
0
 
LVL 12

Accepted Solution

by:
Gibu George earned 500 total points
ID: 24138218
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
 

Expert Comment

by:prototypeit
ID: 24844319
I would use session.setMaxInactiveInterval(ONE_HOUR);
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let’s list some of the technologies that enable smooth teleworking. 
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question