How to use filters in JSP and Servlets for logging information in ServletContext logs ?

A simple web application demonstrating the usage of filters in JSP and Servlets. This application uses a LoggingTimeFilter for logging the time of incoming request and outgoing response in ServletContext's log . This information gets printed on the Server's log displayed on the console.

After implementing filter, just make a request to a server with any implemented Url of JSP or Servlet and see the output at the console. I made a anonymous request to server and got the following output at the server's log console:

Video tutorial to demonstrate @WebFilter annotation.

Using annotation

A simple web application demonstrating the usage of filters in JSP and Servlets. This application uses a LoggingTimeFilter for logging the time of incoming request and outgoing response in ServletContext's log . This information gets printed on the Server's log displayed on the console.

After implementing filter, just make a request to a server with any implemented Url of JSP or Servlet and see the output at the console. I made a anonymous request to server and got the following output at the server's log console: