How to log or view the pages being accessed by the user in Tomcat.

Alessandro A. Garbagnati


If you are working on Tomcat, and you are looking for a Tomcat specific solution (not portable), then you can use the Tomcat 4.x valves, that can be considered as a server-level version of Servlets 2.3 Filters. You can start from The Valve Component, but you will need to take a look at the Tomcat 4.x javadocs for further information.

You can also consider to extends one of the different Loggers that Tomcat 4.x provides. They are also a good example of Valves. Even in this case, start from The Logger Component, but considering referring to the Tomcat 4.x javadocs.

If you prefer a portable, 100% Sun specifications' compliant solution, then you need to use Filters, and I think that you can still obtain what you need with them, that are a powerful (and compliant) solution.
By the way, the Filter concept was originally developed in Tomcat 3.x with the name of "interceptors"...