Yup. You should be using your session object as implementing the sessionbindinglistener.......and from the session binding event, you can find out the session information and for an unbound event, implement your business logic.
sahil -----Original Message----- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Friday, July 30, 2004 10:01 AM To: Struts Users Mailing List (E-mail) Subject: HttpSessionListener vs. HttpSessionBindingListener Hi everyone: I would like some clarification regarding the HttpSessionListener. (We are using servlet spec 2.3) Here's what I want to do: When a session expires, either when a user uses the "logout" feature or due to time-out, I want to delete a certain row from the database. The specifics of which row to delete is stored in an attribute in an "user" object in the session. My existing solution which i don't believe works: Write a class that implements the HttpSessionListener and override the sessionDestroyed(HttpSesssionEvent) method. In the sessionDestroyed method, call the HttpSessionEvent.getSession() to get the session, query the session to get the user and carry on. However, here's an entry in my logs: "java.lang.IllegalStateException: getAttribute: Session already invalidated" So i looked up the Javadocs for the HttpSessionListener and indeed here's the description for HttpSessionListener.sessionDestroyed method: Notification that a session was invalidated. . Note the use of the *past* tense!! Thus, for example, it seems you cannot query the session for anything at this point! Googling produced this page which seems to describe the problem I am facing. http://archives.java.sun.com/cgi-bin/wa?A2=ind0207&L=servlet-interest&F=&S=& P=32332 Since this (and others I found like it) are dated over two years ago, I'd like you comments on: Proposed solution: Seeing as it seems that I cannot query the session for any attributes after it has already been invalidated, I therefore should make my **User** class implement the HttpSessionBindingListener interface and overwrite the valueUnbound method. Is my understanding correct? How do others do this sort of thing? Thank you in advance for any replies! Geeta --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]