Bonjour, Please: how to get code be called when a session is dying with the session still alive avec getAttribute stil working?
Cordialement, Nicolas Silberzahn Digital Airways Everywhere <Internet>Technologies</Internet> www.DigitalAirways.com >-----Message d'origine----- >De : A mailing list for discussion about Sun Microsystem's Java Servlet >API Technology. [mailto:[EMAIL PROTECTED]]De la part de >Bhushan_Bhangale >Envoy� : jeudi 18 juillet 2002 05:39 >� : [EMAIL PROTECTED] >Objet : Re: HttpSessionBindingListener, HttpSessionListener : Session >already invalidated > > >Hi Nicolas, > >The dying of session is an event and HttpSessionListener will be >get called only if certain event happens. The other event is >creation of session. >Using HttpSessionBindingListener you can do some thing by making >the value bound and unbound event happen. > >-----Original Message----- >From: Silber zahn Nicolas [mailto:[EMAIL PROTECTED]] >Sent: Thursday, July 18, 2002 2:07 AM >To: [EMAIL PROTECTED] >Subject: 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/<76227803D20F654BA >920161144 >[EMAIL PROTECTED]> >http://www.apachelabs.org/tomcat-dev/200202.mbox/<20020220103254.B7 >6183-1000 >[EMAIL PROTECTED]> >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, send email to [EMAIL PROTECTED] and include in the body >of the message "signoff SERVLET-INTEREST". > >Archives: http://archives.java.sun.com/archives/servlet-interest.html >Resources: http://java.sun.com/products/servlet/external-resources.html >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > >___________________________________________________________________________ >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body >of the message "signoff SERVLET-INTEREST". > >Archives: http://archives.java.sun.com/archives/servlet-interest.html >Resources: http://java.sun.com/products/servlet/external-resources.html >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
