If You want to track session Attribute like whether there is new session attribute added,removed or replaced during application lifecycle then HttpSessionAttributeListener is for You !
HttpSessionAttributeListener is abstract interface which comes as part of servlet-api.jar which has abstract method such as attributeAdded,attributeRemoved,attributeReplaced.
How it works :
HttpSessionAttributeListener is abstract interface which comes as part of servlet-api.jar which has abstract method such as attributeAdded,attributeRemoved,attributeReplaced.
How it works :
- When new session attribute is added using set then attributeAdded will be called.
HttpSession session = request.getSession(); session.setAttribute("sessionName","LoginIn");
- If you try to set attribute value to some different value which is already present then attributeReplaced will be called. ex. session.setAttribute("sessionName","LoggedIn");