// Create a wrapper of the response so that we can later write to
// the response (add the footer). If we did not do this, we would
// get an error saying that the response has already been
// committed.
GenericResponseWrapper wrapper =
new GenericResponseWrapper((HttpServletResponse) theResponse);
theChain.doFilter(theRequest, wrapper);
out.write(wrapper.getData());
addFooter(out);
out.close();
}