You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nicolas Silberzahn <Ni...@DigitalAirways.com> on 2002/07/17 15:50:14 UTC
HttpSessionBindingListener, HttpSessionListener : Session already invalidated
Bonjour,
I want to do some cleanup when a session dies. I tried to use
HttpSessionBindingListener and then HttpSessionListener
In both case, my code is called AFTER the session had been invalidated:
nothing can be done with the session anymore: it seems to be useless
functionality
Does anyone knows how to get code called BEFORE the sesion dies?
Cordialement,
Nicolas Silberzahn
Digital Airways
Everywhere <Internet>Technologies</Internet>
www.DigitalAirways.com
o Google said
be aware there is a ">" at the end that belongs to the URL...
http://www.apachelabs.org/tomcat-dev/200202.mbox/<76227803D20F654BA920161144
532EB730A3E4@earth.centervilletech.com>
http://www.apachelabs.org/tomcat-dev/200202.mbox/<20020220103254.B76183-1000
00@icarus.apache.org>
http://w6.metronet.com/~wjm/tomcat/2001/Oct/msg00252.html
o Some test code:
public class MySessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent hse) {
HttpSession session = hse.getSession();
try {
session.setAttribute("toto", new MyHttpSessionBindingListener());// so it
will be called when the session dies... (i don't remove it explicitly
elsewhere)
}
catch (Throwable e) {
// removed error logging here
}
public void sessionDestroyed(HttpSessionEvent hse) {
HttpSession session = hse.getSession();
ServletContext application = session.getServletContext();
// a session. getAttribute throws an exception here: Session already
invalidated
}
}
class MyHttpSessionBindingListener implements HttpSessionBindingListener {
public void valueUnbound(HttpSessionBindingEvent hse) {
HttpSession session = hse.getSession();
ServletContext application = session.getServletContext();
System.out.println("valueUnbound");
Object o = session.getAttribute("Caddy"); // a session. getAttribute
throws an exception here: Session already invalidated
// cleanup here...
}
public void valueBound(HttpSessionBindingEvent hse) {
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>