Context example

In this section, we'll modify the devguide web application to install a custom class, a context parameter, a filter, a ServletContextListener, and a ServletRequestListener. When the application is run, watch the console output to see when the filters and listeners are invoked.

Deployment descriptor

Edit the devguide web application's web.xml deployment descriptor to add in the following lines:

<listener> <listener-class> com.swengsol.listeners.MyServletContextListener </listener-class> </listener> <listener> <listener-class> com.swengsol.listeners.MyServletRequestListener </listener-class> </listener> <context-param> <param-name>contextVariable</param-name> <param-value>Example Context Value</param-value> </context-param> <filter> ...

Get Tomcat 6 Developer's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.