!(response instanceof HttpResponse)) {
context.invokeNext(request, response);
return;
}
HttpRequest hrequest = (HttpRequest) request;
HttpResponse hresponse = (HttpResponse) response;
HttpServletRequest hreq =
(HttpServletRequest) hrequest.getRequest();
// Log pre-service information
log("REQUEST URI =" + hreq.getRequestURI());
log(" authType=" + hreq.getAuthType());
log(" characterEncoding=" + hreq.getCharacterEncoding());
log(" contentLength=" + hreq.getContentLength());
log(" contentType=" + hreq.getContentType());
log(" contextPath=" + hreq.getContextPath());
Cookie cookies[] = hreq.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++)
log(" cookie=" + cookies[i].getName() + "=" +
cookies[i].getValue());
}
Enumeration hnames = hreq.getHeaderNames();
while (hnames.hasMoreElements()) {
String hname = (String) hnames.nextElement();
Enumeration hvalues = hreq.getHeaders(hname);
while (hvalues.hasMoreElements()) {
String hvalue = (String) hvalues.nextElement();
log(" header=" + hname + "=" + hvalue);
}
}
log(" locale=" + hreq.getLocale());
log(" method=" + hreq.getMethod());
Enumeration pnames = hreq.getParameterNames();
while (pnames.hasMoreElements()) {
String pname = (String) pnames.nextElement();
String pvalues[] = hreq.getParameterValues(pname);
StringBuffer result = new StringBuffer(pname);
result.append('=');
for (int i = 0; i < pvalues.length; i++) {
if (i > 0)
result.append(", ");
result.append(pvalues[i]);
}
log(" parameter=" + result.toString());
}
log(" pathInfo=" + hreq.getPathInfo());
log(" protocol=" + hreq.getProtocol());
log(" queryString=" + hreq.getQueryString());
log(" remoteAddr=" + hreq.getRemoteAddr());
log(" remoteHost=" + hreq.getRemoteHost());
log(" remoteUser=" + hreq.getRemoteUser());
log("requestedSessionId=" + hreq.getRequestedSessionId());
log(" scheme=" + hreq.getScheme());
log(" serverName=" + hreq.getServerName());
log(" serverPort=" + hreq.getServerPort());
log(" servletPath=" + hreq.getServletPath());
log(" isSecure=" + hreq.isSecure());
log("---------------------------------------------------------------");
// Perform the request
context.invokeNext(request, response);
// Log post-service information
log("---------------------------------------------------------------");
log(" authType=" + hreq.getAuthType());
log(" contentLength=" + hresponse.getContentLength());
log(" contentType=" + hresponse.getContentType());
Cookie rcookies[] = hresponse.getCookies();
for (int i = 0; i < rcookies.length; i++) {
log(" cookie=" + rcookies[i].getName() + "=" +
rcookies[i].getValue() + "; domain=" +
rcookies[i].getDomain() + "; path=" + rcookies[i].getPath());
}
String rhnames[] = hresponse.getHeaderNames();
for (int i = 0; i < rhnames.length; i++) {
String rhvalues[] = hresponse.getHeaderValues(rhnames[i]);
for (int j = 0; j < rhvalues.length; j++)
log(" header=" + rhnames[i] + "=" + rhvalues[j]);
}
log(" message=" + hresponse.getMessage());
log(" remoteUser=" + hreq.getRemoteUser());
log(" status=" + hresponse.getStatus());
log("===============================================================");
}