10.7. Recognizing Session Creation and Destruction

Classes that implement the ServletContextListener and ServletContextAttributeListener interfaces respond to changes in the servlet context, which is shared by all servlets and JSP pages in the Web application. But, with session tracking (Section 2.10), data is stored in per-user HttpSession objects, not in the servlet context. What if you want to monitor changes to this user-specific data? That’s the job of the HttpSessionListener and HttpSessionAttributeListener interfaces. This section discusses HttpSessionListener, the listener that is notified when a session is created or destroyed (either deliberately with invalidate or by timing out). Section 10.9 discusses HttpSessionAttributeListener ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.