Home  >  Article  >  Java  >  What is a listener? What does a listener do?

What is a listener? What does a listener do?

PHP中文网
PHP中文网Original
2017-06-21 17:04:5826275browse

1 Overview

1. What is a listener?

A component that monitors the operation of the Web server and takes preset processing measures when a specific event occurs.

2. The role of the listener

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.

3. Listening type

The Servlet specification mainly provides listeners for monitoring objects in the three major scopes of application\session\request.

4. Custom listeners need to be registered. When two registration forms exist at the same time, it is equivalent to only one registration form, and the listener is not affected.

2 ServletContext related listeners

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.

Three ServletRequest related listeners

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.

Four HttpSession related listeners

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Share some terms of JMSNext article:Share some terms of JMS