10.9. Watching for Changes in Session Attributes

OK, so HttpSessionListener lets you detect when a session is created or destroyed. But, since session attributes are removed before session destruction, this listener does not let you clean up attributes that are in destroyed sessions. That’s the job of the HttpSessionAttributeListener interface. Use of this interface involves the following steps.

1.
Implement the HttpSessionAttributeListener interface. This interface is in the javax.servlet.http package.
2.
Override attributeAdded, attributeReplaced, and attributeRemoved. The attributeAdded method is triggered when a new attribute is added to a session. When a new value is assigned to an existing session attribute, attributeAdded is triggered ...

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.