servlet listener for JSPSource: Http://blog.csdn.net/phoenix_17th/article/details/3868670Servlet listener is used to listen to the occurrence of some important events, the listener object can be before the event, After the occurrence can do some necessary processing. At present, Servlet2.4 and JSP2.0 are commonly used
7A listener interface, divided into
3Class:
1. servlet Context for listening (application level):
Used to monitor the creation and deletion of ServletContext objects, as well as the addition, deletion, and modification of attributes, the listener needs to use the following two interface classes:
(1) Servletcontextattributelistener: Listen to the operation of the ServletContext attribute, such as add, delete, modify
attributeadded (Servletcontextattributeevent e) is called when an attribute is added
attributereplaced (servletcontextattributeevent e) Called when modifying properties
Attributeremoved (servletcontextattributeevent e) Called when the property is deleted
(2) Servletcontextlistener: Monitoring the creation and deletion of ServletContext objects
Contextinitialized (Servletcontextevent SCE) called when initializing
Called when contextdestroyed (Servletcontextevent SCE) is destroyed, that is, when the server is reloaded
2. Listen for HTTP sessions (Session level):
Used to listen for HTTP session activity and property settings in an HTTP session, to listen for HTTP session active and passivate situations, etc., the listener needs to use the following multiple interface classes:
(1) Httpsessionlistener: Monitor the operation of HttpSession
Sessioncreate (httpsessionevent se) is called at initialization time;
Called when sessiondestroyed (Httpsessionevent se) is destroyed, that is, when the user logs off
(2) Httpsessionactivationlistener: Active and passivate conditions for listening to HTTP sessions
(3) Httpsessionattributelistener: Listen for property actions in HttpSession
attributeadded (httpsessionbindingevent se) is called when an attribute is added
attributeremoved (httpsessionbindingevent se) is called when the property is deleted
attributereplaced (httpsessionbindingevent se) called when modifying properties
(4) httpsessionbindinglistener
Bindinglistenerhave a2a method, Valuebound (httpsessinbindingevent)and theValueunbount (httpsessionbindingevent).
ImplementBindinglistenerListener for Interfacewhen an object is bound to aSessionTrigger whenValueboundEvents,Trigger when unboundValueunboundevent.
3. Listen for client requests (Requst level):
Listening for client requests is a newly added new technology in the Servlet2.4 specification, using the following interfaces:
(1) Servletrequestlistener interface class
Requestdestroyed (servletrequestevent e) listens for the destruction client, which is called when the Request.removeattribute ("xxx") is executed
Requestinitialized (servletrequestevent e) listens for client-side requests
(2) Servletrequestattributelistener interface class
attributeadded (servletrequestattributeevent e) to listen for property additions
Attributeremoved (servletrequestattributeevent e) to listen for property deletions
attributereplaced (servletrequestattributeevent e) listening for attribute substitution
From for notes (Wiz)