final HttpServletResponse httpResponse = (HttpServletResponse) response;
// Infer the content type based on the path of the request.
String path = ((HttpServletRequest)request).getRequestURI();
ContextHandler.SContext sContext = (ContextHandler.SContext)config.getServletContext();
MimeTypes mimes = sContext.getContextHandler().getMimeTypes();
Buffer mimeBuffer = mimes.getMimeByExtension(path);
String mime = mimeBuffer != null ? mimeBuffer.toString() : "text/html";
// If it is HTML (default), force the character set to utf-8.
// This is to avoid the following security issue:
// http://openmya.hacker.jp/hasegawa/security/utf7cs.html