This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
Is it not possible to access session attributes in the method sessionDestroyed() of HttpSessionListener by using the session object returned from HttpSessionEvent??
Correct; it is not possible. As discussed in Section 10.7 of More Servlets and JSP, the attributes are removed before sessionDestroyed is called. You need to catch them in the attributeRemoved method of HttpSessionAttributeListener. I haven't found much use for sessionDestroyed other than listeners that merely keep track of the number of active sessions (which is actually helpful to know). Cheers- - Marty
thanx marty, i found it the hard way. actually i had to reset the user login status in the database when session is destroyed. HttpSessionListener did not help me, i modified my design and now using HttpSessionBindingListener. This is clean and works perfect. Thanx for confirming... SHankar
How do I get the actual session attribute object? I have a servlet that for various reasons needs to open a DB connection with each session, and I want to close those connections as the sessions time out. How do i get the actual Connection object that is the value of my session attribute, so I can call close() on it? Thanks, John