tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Problem with session counting
Date Mon, 30 Aug 2004 13:26:44 GMT

Does it make a difference if you make the counter int not static and the two interface methods
that increment/decrement the counter synchronized?

Yoav Shapira
Millennium Research Informatics

>-----Original Message-----
>From: Michael S├╝dkamp []
>Sent: Monday, August 30, 2004 9:24 AM
>Subject: Problem with session counting
>I have problems tracking the lifecycle of my sessions. I use the session
>listener code below.
>I test my app with Apache JMeter and run a test with 10 threads for about 3
>Then I stop the test and let the sessions time out (session timeout is set
>to 5 min)
>Almost everytime the session counter is greater than 0 when I expect it to
>be 0.
>My logs show that my session count during the test goes beyond the expected
>10 sessions (it rises to 13-16 sessions depending on the test duration).
>The Tomcat manager reports 10 sessions during the test and 0 sessions after
>all sessions have timesd out.
>Is there anything wrong I can do with my sessions so that the created and
>destroyed sessions are not balanced?
>public class SimpleSessionListener implements HttpSessionListener {
>  private static int sessionCount = 0;
>  public void sessionCreated(HttpSessionEvent event) {
>    sessionCount++;
>    System.out.println("sessionCreated: sessionCount="+sessionCount);
>  }
>  public void sessionDestroyed(HttpSessionEvent event) {
>    sessionCount--;
>    System.out.println("sessionDestroyed: sessionCount="+sessionCount);
>  }
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message