TimerFilter : A Simple HTTP Servlet Filter

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class TimerFilter implements Filter {

	public void destroy() {

	public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
		long startTime = System.currentTimeMillis();
		filterChain.doFilter(req, res);
		long stopTime = System.currentTimeMillis();
		System.out.println("took " + (stopTime-startTime) + " milli seconds.");


	public void init(FilterConfig arg0) throws ServletException {






You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

AddThis Social Bookmark Button

Similar Posts

Comments are closed.