A component that monitors the operation of the Web server and takes preset processing measures when a specific event occurs.
The listener provides a way to obtain the running status of the server and dynamically intervene. During the operation of the server Intervene promptly when designated changes occur.
The Servlet specification mainly provides listeners for monitoring objects in the three major scopes of application\session\request.
1. ServletContextListener: Mainly used to monitor the creation and destruction of ServletContext, that is, the Servlet container.
2. ServletContextAttributeListener: Mainly used to monitor changes in attributes in the ServletContext scope.
1. ServletRequestListener: Mainly used to monitor the creation and destruction of request objects.
2. ServletRequestAttributeListener: Mainly used to monitor changes in attributes in the request scope.
1.HttpSessionListener: used to monitor the creation and destruction of session objects.
2.HttpSessionAttributeListener: Users monitor changes in attributes in the session scope.
3.HttpSessionBindingListener: It is implemented by the entity class and does not require registration. It is used to listen for events when entity objects are added to the session scope and deleted from the session scope. 4.HttpSessionActivationListener: The entity class must implement the Serializable interface while implementing this interface, and the entity class object must be saved in the
session scope. Used to monitor the serialization and deserialization events of entity class objects.
The above is the detailed content of What is a listener? What does a listener do?. For more information, please follow other related articles on the PHP Chinese website!