The Java Servlet Specification supports application level events for controlling interactions with the ServletContext and HttpSession objects and for managing the resources that a web module uses.
Application event listeners are classes that implement one or more of the servlet event listener interfaces. Application events notify listener objects when servlet contexts and sessions are initialized and destroyed, as well as when attributes are added or removed from a context or session.
The IDE provides a wizard to help you create listener classes. Use the servlet context listener templates to create listener classes that manage resources or state held at a virtual machine level for the web module:
Use the HTTP session listener templates to create listener classes that manage state or resources associated with a series of requests made to a web module from the same client or users:
You use the listener element to declare listeners in the deployment descriptor (web.xml). List the listener elements in the order in which they are to be invoked.
To create a listener:
![]() |
If you want to keep your source separate from your class files, you must mount the directory above the package root and you must use the Options window to select WEB-INF/classes as the project's target directory for the External Compiler. Doing so ensures that code completion and compiling are supported by the IDE. |
![]() |
To view the API documentation for servlet listeners, choose
View ![]() ![]() |
For more information about listeners, see the Java Servlet Specification available at http://java.sun.com/products/servlet/download.html.
See Also | |
---|---|
About Servlet Listeners Setting Listener Properties Adding a Listener to the Deployment Descriptor Where to Put Web Module Files |