Object response = facesContext.getExternalContext().getResponse();
if(response instanceof HttpServletResponse) {
HttpServletResponse httpResp = (HttpServletResponse) response;
if (!httpResp.isCommitted()) {
httpResp.reset();
httpResp.setContentType("text/html; charset=UTF-8");
Writer writer = httpResp.getWriter();
debugHtml(writer, facesContext, ex);