Perform the actual filtering. Log request parameters and attributes
to the ServletContext log
ServletContext sc = filterConfig.getServletContext();
// preprocess the request
HttpServletRequest hrs = (HttpServletRequest)request;
sc.log("Request Attributes:");
sc.log("Method: " + hrs.getMethod());
sc.log("QueryString: " + hrs.getQueryString());
sc.log("Context: " + hrs.getContextPath());
sc.log("RequestURL: " + hrs.getRequestURL());
sc.log("RequestURI: " + hrs.getRequestURI());
sc.log("PathInfo: " + hrs.getPathInfo());
sc.log("ServletPath: " + hrs.getServletPath());
// enumerate all parameters
sc.log("Parameters:");
for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
String name = (String) e.nextElement();
String vals[] = request.getParameterValues(name);
StringBuffer out = new StringBuffer();
out.append(name + "=");
// each parameter may have multiple values
for(int i = 0; i < vals.length; i++) {
out.append(vals[i]);
}
// remove the trailing comma
sc.log(out.substring(0, out.length() - 1));
}
// invoke the next filter in the chain
chain.doFilter(request, response);