Debug.logError(msg + ": " + e, module);
try {
Writer writer = new StringWriter();
ScreenRenderer screens = new ScreenRenderer(writer, null, new HtmlScreenRenderer());
screens.populateContextForRequest(request, response, servletContext);
<BUG>screens.getContext().put("errorMessage", e.toString());
</BUG>
screens.render(DEFAULT_ERROR_TEMPLATE);
response.setContentType("text/html");
<BUG>response.getOutputStream().write(writer.toString().getBytes());
</BUG>
writer.close();

Debug.logError(msg + ": " + e, module);
try {
Writer writer = new StringWriter();
ScreenRenderer screens = new ScreenRenderer(writer, null, new HtmlScreenRenderer());
screens.populateContextForRequest(request, response, servletContext);
screens.getContext().put("errorMessage", msg + ": " + e);
screens.render(DEFAULT_ERROR_TEMPLATE);
response.setContentType("text/html");
response.getWriter().write(writer.toString());
writer.close();
