PrintWriter pw = response.getWriter(); pw.write(content);
ByteBufferOutputStream bos = null; if (useGzip) { ConfiguredHttpServlet .setGzipContentEncoding((HttpServletResponse) response);  if (hasSaveStateFieldMarker == false) { bos = new ByteBufferOutputStream(content.length());  outputStream = new GZIPOutputStream(bos, content.length());  if (LOG.isDebugEnabled()) { LOG .debug("GZip content of interactive buffer and keep result. (no state field marker)"); } } else { outputStream = new GZIPOutputStream(outputStream, content .length());  if (LOG.isDebugEnabled()) { LOG .debug("GZip content of interactive buffer. (state field marker presn"); } } } else { if (LOG.isDebugEnabled()) { LOG.debug("Dont't use GZip to send content."); } }  Writer writer = new OutputStreamWriter(outputStream, AbstractHtmlService.RESPONSE_CHARSET);  if (hasSaveStateFieldMarker == false) { writer.write(content);  } else { String saveStateFieldMarker = StateFieldMarkerTools .getStateFieldMarker(facesContext); if (saveStateFieldMarker == null) { throw new FacesException( "Save state field marker is null !"); }  StateManager stateManager = facesContext.getApplication() .getStateManager();  SerializedView serializedView = stateManager .saveSerializedView(facesContext);  String saveValue = StateFieldMarkerTools.getStateValue( facesContext, serializedView);  if (LOG.isDebugEnabled()) { LOG.debug("Save value=" + saveValue); }  for (int start = 0;;) { int offset = content.indexOf(saveStateFieldMarker, start); if (offset < 0) { if (start < content.length()) { writer.write(content.substring(start)); } break; } if (offset > start) { writer.write(content.substring(start, offset)); } writer.write(saveValue); start = offset + saveStateFieldMarker.length(); } }  writer.close();  outputStream.close();  if (bos != null) { gzippedContent = bos.toByteArray();  responseStream.write(gzippedContent); }
        public void sendBuffer(FacesContext facesContext,                ServletResponse response) throws IOException {            boolean useGzip = this.useGzip;            if (useGzip) {                useGzip = ParametredHttpServlet.hasGzipSupport(facesContext);            }            if (LOG.isTraceEnabled()) {                LOG.trace("Send interactiveBuffer[" + id + "] (gzip support="                        + useGzip + ")");            }            if (gzipped != null) {                if (useGzip) {                    ParametredHttpServlet                            .setGzipContentEncoding((HttpServletResponse) response);                    OutputStream out = response.getOutputStream();                    out.write(gzipped);                    return;                }                // Ca peut toujours arriver !                OutputStream out = response.getOutputStream();                ByteArrayInputStream bin = new ByteArrayInputStream(gzipped);                GZIPInputStream gzip = new GZIPInputStream(bin, gzipped.length);                try {                    byte bout[] = new byte[4096];                    for (;;) {                        int ret = gzip.read(bout);                        if (ret < 1) {                            break;                        }                        out.write(bout, 0, ret);                    }                } finally {                    gzip.close();                }                return;            }            PrintWriter pw = response.getWriter();            pw.write(content);        }