Creating a Web Application Listener

See Also

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 application 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 Web Application Listener wizard to create listener classes that manage resources or state held at a virtual machine level for the web application.

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:

  1. In the Projects or Files window, right-click the package node and choose New > Other from the pop-up menu.
  2. Under Categories, select Web. Under File Types, select Web Application Listener.
  3. Follow the instructions in the New Web Application Listener wizard and click Finish. The source code appears in the Source Editor.

For more information about listeners, see the Java Servlet Specification available at

.

See Also
About Web Application Listeners
Registering a Web Application Listener

Legal Notices