public final class BufferedServletOutput extends Object
ServletResponse wrappers.
It allows to buffer the output without committing it to the underlying response.
Also it exposes methods to access the buffers for the writer and output stream.
When calling close it will automatically spool the buffers to the underlying response.| Modifier and Type | Class and Description |
|---|---|
static class |
BufferedServletOutput.ResponseWriteMethod |
| Constructor and Description |
|---|
BufferedServletOutput(javax.servlet.ServletResponse wrappedResponse)
Creates a new servlet output buffering both the underlying writer and output stream.
|
BufferedServletOutput(javax.servlet.ServletResponse wrappedResponse,
StringWriter writer,
ByteArrayOutputStream outputStream)
Creates a new servlet output using the given StringWriter and OutputStream as buffers.
|
| Modifier and Type | Method and Description |
|---|---|
void |
flushBuffer()
Will not commit the response, but only make sure that the wrapped response's
flushBuffer() is executed, once this close() is called |
byte[] |
getBufferedBytes() |
String |
getBufferedString() |
BufferedServletOutput.ResponseWriteMethod |
getWriteMethod() |
void |
resetBuffer()
Flushes the buffers bound to this object.
|
public BufferedServletOutput(javax.servlet.ServletResponse wrappedResponse)
wrappedResponse - the wrapped responsepublic BufferedServletOutput(javax.servlet.ServletResponse wrappedResponse,
StringWriter writer,
ByteArrayOutputStream outputStream)
wrappedResponse - the wrapped responsewriter - the writer to use as buffer (may be null in case you don't want to buffer the writer)outputStream - the ByteArrayOutputStream to use as buffer for getOutputStream() (may be null in case
you don't want to buffer the output stream)public BufferedServletOutput.ResponseWriteMethod getWriteMethod()
BufferedServletOutput.ResponseWriteMethod.OUTPUTSTREAM in case getOutputStream() has been called,
BufferedServletOutput.ResponseWriteMethod.WRITER in case getWriter() has been called, null in case none of those have been
called yet.public String getBufferedString()
getWriter()IllegalStateException - in case getWriter() has not been called yet or the writer was not buffered.public byte[] getBufferedBytes()
getOutputStream()IllegalStateException - in case getOutputStream() has not been called yet or the output stream was not buffered.public void resetBuffer()
ServletResponse.flushBuffer() of the underlying response.public void flushBuffer()
flushBuffer() is executed, once this close() is calledCopyright © 2013–2020 Adobe. All rights reserved.