public void doFilter(ServletRequest theRequest,
ServletResponse theResponse,
FilterChain theChain) throws IOException, ServletException {
OutputStream out = theResponse.getOutputStream();
addHeader(out);
// 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();
}
Perform the filter function. Called by the container upon a request
matching the filter pattern defined in web.xml. |