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> <filter-name>MyAppFilter</filter-name> <filter-class>com.swengsol.filters.MyFilter</filter-class> </filter> <filter-mapping...