}
doBeforeProcessing(request, response);
PrintWriter out = response.getWriter();
CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse) response);
chain.doFilter(request, wrapper);
String contentType = wrapper.getContentType();
System.out.println(getUserAgent((HttpServletRequest)request));
if (wrapper.getContentType().contains("text/html")) {
CharArrayWriter caw = new CharArrayWriter();
String wrapperString = wrapper.toString();
wrapperString = wrapperString.replace("</head>",
"<script type='text/javascript' src='../resources/ASCIIMathML.js'></script></head>");
wrapperString = wrapperString.replace("<code>", "amath ");
wrapperString = wrapperString.replace("</code>", " endamath");
caw.write(wrapperString);
// System.out.println(wrapperString);
response.setContentLength(caw.toString().length());
out.write(caw.toString());
} else {
out.write(wrapper.toString());
}
out.close();
doAfterProcessing(request, response);
}