Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session Does Not Time Out

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic