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

Session Does Not Time Out

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi JiaPei,
Please post your code so we may look at it.
Regards,
Ryan
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 390
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic