The Servlet API comes with a set of event classes and listener interfaces for event-driven programming in servlet/JSP applications. All event classes are derived from java.util.Event and listeners are available in three different levels, the ServletContext level, the HttpSession level, and the ServletRequest level.
This chapter demonstrates how to write listeners and use them in servlet/JSP applications. One of the listener interfaces, javax.servlet.AsyncListener, was a new addition to Servlet 3.0 and is discussed in Chapter 11, “Asynchronous Operations.”
Listener Interfaces and Registration
The listener interfaces for creating listeners are part of the javax.servlet and javax.servlet.http packages. They are listed ...