Use the Web Application Listeners section of the web.xml Visual Editor to add, remove, and view the deployment information of your web application's listeners. Web application listeners give you more control over interactions with the ServletContext and HttpSession objects and let you efficiently manage the resources used by a web application. Web application listeners are classes that implement one or more of the servlet event listener interfaces. Application events notify web application listeners when servlet contexts and sessions are initialized and destroyed, as well as when attributes are added or removed from a context or session.
To deploy a web application listener, you must register it in the web.xml file. When you do this, you provide information needed by the server to deploy the web application listener. You tell the server which class should be loaded when a web application listener is called.
Before you can register a web application listener in the web.xml file, you must create it in the New File wizard or import it from your existing sources. You can use the Name and Location panel of the New File wizard to register a web application listener. If you have not done so, or if you want to modify a registered web application listener's deployment information, use the Web Application Listeners section of the web.xml Visual Editor.
You open the web.xml Visual Editor from the Projects window by expanding the Web Pages node, then the WEB-INF node, and then double-clicking the web.xml file. Click General at the top of the editor to open the General section, then click the Web Application Listeners header to open the Web Application Listeners section.
Click Add to define the listener element with the following properties: