public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
	throws IOException, ServletException {
		System.out.println("CompressingFilter.doFilter()");
		if (req instanceof HttpServletRequest) {
			HttpServletRequest request = (HttpServletRequest) req;
			System.out.println("CompressingFilter.doFilter(): " + request.getRequestURI());
			HttpServletResponse response = (HttpServletResponse) resp;
			// XXX should maybe use getHeaders() and iterate?
			String acceptableEncodings = request.getHeader("accept-encoding");
			if (acceptableEncodings != null
					&& acceptableEncodings.indexOf("gzip") != -1) {

				System.out.println("CompressingFilter.doFilter(): doing compression!");

				// Create a delegate for the Response object; all methods
				// are directly delegated except getOutputStream.
				// This wrapper class is defined below.
				GZipResponseWrapper wrappedResponse = new GZipResponseWrapper(
						response);
				try {
					chain.doFilter(req, wrappedResponse);
				} finally {
					wrappedResponse.flush();
				}
				return;
			}
		}
		System.out.println("CompressingFilter.doFilter(): bottom");
		chain.doFilter(req, resp);
	}