Package org.zkoss.web.servlet

## Class BufferedResponse

- java.lang.Object
- - javax.servlet.ServletResponseWrapper
  - - org.zkoss.web.servlet.BufferedResponse

- All Implemented Interfaces:
    `javax.servlet.ServletResponse`

      public class BufferedResponse
      extends javax.servlet.ServletResponseWrapper

  A servlet response that uses another writer or stream as the output.
  Author:
    tomyeh

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `flushBuffer()` |
    `static javax.servlet.ServletResponse` | `getInstance​(javax.servlet.ServletResponse response, java.io.OutputStream stream)` | Returns a buffered response with a output stream, if stream is not null; or the original response if stream is null.
    `static javax.servlet.ServletResponse` | `getInstance​(javax.servlet.ServletResponse response, java.io.Writer writer)` | Returns a buffered response with a writer, if writer is not null; or the original response if writer is null.
    `javax.servlet.ServletOutputStream` | `getOutputStream()` |
    `java.io.PrintWriter` | `getWriter()` |
    `void` | `resetBuffer()` | Useful only if StringWriter or ByteArrayOutputStream is used to construct this object.

    - ### Methods inherited from class javax.servlet.ServletResponseWrapper

      `getBufferSize, getCharacterEncoding, getContentType, getLocale, getResponse, isCommitted, isWrapperFor, isWrapperFor, reset, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale, setResponse`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getInstance

          public static final javax.servlet.ServletResponse getInstance​(javax.servlet.ServletResponse response,
                                                                        java.io.Writer writer)

      Returns a buffered response with a writer, if writer is not null; or the original response if writer is null. If response is HttpServletResponse, `HttpBufferedResponse.getInstance(javax.servlet.http.HttpServletResponse, java.io.Writer)` is returned. It is smart enough not to wrap the same writer twice.

    - #### getInstance

          public static final javax.servlet.ServletResponse getInstance​(javax.servlet.ServletResponse response,
                                                                        java.io.OutputStream stream)

      Returns a buffered response with a output stream, if stream is not null; or the original response if stream is null. If response is HttpServletResponse, `HttpBufferedResponse.getInstance(javax.servlet.http.HttpServletResponse, java.io.Writer)` is returned. It is smart enough not to wrap the same stream twice.

    - #### getWriter

          public java.io.PrintWriter getWriter()
                                        throws java.io.IOException

      Specified by:
        `getWriter` in interface `javax.servlet.ServletResponse`
      Overrides:
        `getWriter` in class `javax.servlet.ServletResponseWrapper`
      Throws:
        `java.io.IOException`

    - #### getOutputStream

          public javax.servlet.ServletOutputStream getOutputStream()
                                                            throws java.io.IOException

      Specified by:
        `getOutputStream` in interface `javax.servlet.ServletResponse`
      Overrides:
        `getOutputStream` in class `javax.servlet.ServletResponseWrapper`
      Throws:
        `java.io.IOException`

    - #### flushBuffer

          public void flushBuffer()
                           throws java.io.IOException

      Specified by:
        `flushBuffer` in interface `javax.servlet.ServletResponse`
      Overrides:
        `flushBuffer` in class `javax.servlet.ServletResponseWrapper`
      Throws:
        `java.io.IOException`

    - #### resetBuffer

          public void resetBuffer()

      Useful only if StringWriter or ByteArrayOutputStream is used to construct this object.
      Specified by:
        `resetBuffer` in interface `javax.servlet.ServletResponse`
      Overrides:
        `resetBuffer` in class `javax.servlet.ServletResponseWrapper`