javaweb development technology - Listener

Listeners defined : is dedicated to the event or the status of other objects happened to change the listening and the corresponding object processing, when the monitored object changes take immediate action.

defining web listener : servlet specification a particular class definition. For monitoring the process of creation and destruction ServletContext, HttpSession, ServletRequest and other domain objects, for event listener to modify the properties of these domain objects occurs, you can do some necessary treatment after the occurrence of an event occurred before.

web listener uses:

  1, or count the number of online users online

  2, the system is the system load initialization information

  3, site traffic statistics

  4, and in conjunction with spring

Listeners create : to achieve the appropriate interface, configure listener-class in web.xml

Kicking sequence listener : the boot sequence in web.xml listener is registered in the order of web.xml

Listener loading sequence, the filter, the servlet's : Listener> Filter> the servlet

Listener Category:

  By listening if the object is divided:

    For monitoring the application environment objects (ServletContext) event listeners

    Objects (HttpSession) is used to monitor a user session event listeners

    Object (the ServletContext) a request message for monitoring the event listener

  The event is divided according to listening:

    Monitor domain object itself to create an event listener destroyed

    Property monitor domain object to add or remove event listeners

    Monitor the status of an object bound to the domain HttpSession event listener

Session passivation mechanisms:

  Session object lies in the nature of the server is not frequently used is temporarily serialized to a file system or database system, when used in the generation of memory deserialized, the entire process is completed automatically by the server

Servlet3.0 under use listener:

To use annotations @WebListener, and implement at least one of the following interfaces:

  ServletContextListener

  ServletContextAttributeListener

  ServletRequestListener

  ServletRequestAttributeListener

  HttpSessionListener

  HttpSessionAttributelistener

 

Guess you like

Origin www.cnblogs.com/niuyg928/p/11256496.html