Servlet filters ensure that any accesses to page resources (servlets/jsp/html/jpg/...) go first through the filter and then to the resource, and back out via the filter. This allows you to have one place to handle such things as compression, login, caching, and monitoring.
This site has more about servlet filters as well as a number of examples:
http://wiki.java.net/bin/view/Javapedia/ServletFilter I have created a servlet filter that tracks performance of all pages. You can see a live demo at
http://www.fdsapi.com and read about it at
http://www.jamonapi.com. You can get it working in about 5 minutes without making coding changes to your application.