tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Problem with session
Date Tue, 09 Oct 2007 15:32:04 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alex,

Alex79 wrote:
> You mentionned a session listener, can you point me out to a tutorial on how
> to do it?

Easy: write a class that implements
javax.servlet.http.HttpSesionListener and then enable it in your web.xml
file like this:

    <listener>
        <listener-class>package.for.your.Class</listener-class>
    </listener>

<listener>s are defined after <filter>s in your web.xml file.

> Are there any generic session listener that I could use out of the
> box?

Not really, but they're really easy to write: just implement two
methods. You're really only interested in the "destroyed" method:

public void sessionDestroyed(HttpSessionEvent se)
{
    Session s = se.getSession();

    logger.debug("Session " + s.getSessionId() + " is being destroyed",
                 new Throwable());
}

This will log a stack trace whenever a session is destroyed. You should
be able to see what component is calling session.invalidate originally.
Hopefully, you are using a logger that will make a nice stack trace for
you. Otherwise, you can use a StringWriter or something along with
Throwable.printStackTrace().

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHC5709CaO5/Lv0PARAlc8AKDCBdqVq5zh8HMniESsISLz2Dx3bgCfQ+vK
EF1H7zOFKcDtU6FtfqPbnxc=
=KTvb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message