aspose file tools*
The moose likes Servlets and the fly likes Session Does Not Time Out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Does Not Time Out" Watch "Session Does Not Time Out" New topic
Author

Session Does Not Time Out

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
As soon as a user successfully logs in the web site, I create a session:
HttpSession session = request.getSession();
student.setName( request.getParameter("username") );
session.setAttribute( "user", user );
and specify <session-timeout> in the web.xml file:
<session-config>
<session-timeout>1</session-timeout>
</session-config>
I set it to one minute for testing purpose.
when a subsequent request is received, I do some testing:
HttpSession session = request.getSession( false );
if ( session == null )
{
// do something
}
I wait two minutes for the session to time out; but, my session does not seem to become "null". I use Tomcat. Is there anything wrong with my code?
Bill Wang
Ranch Hand

Joined: Jun 28, 2001
Posts: 31
It seems it is a problem with some web container implementation. Which version of Tomcat are you using? I have similar problem with Websphere Test Environment V4.0. You can let your object implements HttpSessionBindingListener and calculate the time between valueBound and valueUnbound to see if it is one minute.
Hope it helps


SCJP<br />SCWCD<br />SCEA Part I
Bill Wang
Ranch Hand

Joined: Jun 28, 2001
Posts: 31
It seems it is a problem with some web container implementation. Which version of Tomcat are you using? I have similar problem with Websphere Test Environment V4.0. You can let your object implements HttpSessionBindingListener and calculate the time between valueBound and valueUnbound to see if it is one minute.
Hope it helps

Bill
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I use the Tomcat 4.1.18. The session does not seem to time out even after 3 or 4 minutes.
Ryan Bailey
Ranch Hand

Joined: Feb 26, 2002
Posts: 134
Hi JiaPei,
Please post your code so we may look at it.
Regards,
Ryan


SCJP 1.4, SCWCD
Java: The power, elegance, and simplicity of a hand grenade
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
My code is posted at the top of this thread. Please let me know if any other code has to be posted for your diagnostic help.
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
Post the whole code.
If what you have there is the whole code then one can not determine if session timed out or not based on that.
 
 
subject: Session Does Not Time Out