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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.