com.lowagie.servlets
Class BufferedResponse

java.lang.Object
  |
  +--HttpServletResponseWrapper
        |
        +--com.lowagie.servlets.BufferedResponse

public class BufferedResponse
extends HttpServletResponseWrapper

Wraps an HttpServletResponse instance, filtering any attempt to write or flush its output. The data written to the response is store in a memory buffer.

Author:
Marcelo Vanzin
See Also:
Serialized Form

Nested Class Summary
private static class BufferedResponse.ByteArrayServletStream
          Implements a ServletOutputStream that writes to a memory buffer.
 
Field Summary
private  String declaredContentType
           
private  int declaredLength
           
private  boolean isModified
           
private  BufferedResponse.ByteArrayServletStream out
           
private  PrintWriter wOut
           
 
Constructor Summary
BufferedResponse(HttpServletResponse response)
          Constructs a new BufferedResponse, wrapping the response passed.
 
Method Summary
 void flushBuffer()
          Filters calls to flushBuffer() so that no data is written to the response before executing the output filter.
 InputStream getData()
          Returns a InputStream with the data currently stored in the memory buffer..
 String getDeclaredContentType()
          Returns the content type declared by the called resource.
 int getDeclaredLength()
          Returns the content length declared by the called resource.
 ServletOutputStream getOutputStream()
          Returns a OutputStream to the memory buffer.
 PrintWriter getWriter()
          Returns a PrintWriter to the memory buffer.
 boolean isModified()
          Says if the resource called has been modified or not.
 void setContentLength(int length)
          Does not let the content length be set, but stores it in a variable in case it is needed later.
 void setContentType(String type)
          Does not let the content type be set, but stores it in a variable in case it is needed later.
 void setStatus(int sc)
          If the status set if SC_NOT_MODIFIED, sets a flag so that the output filter knows that the buffer may be empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

private BufferedResponse.ByteArrayServletStream out

wOut

private PrintWriter wOut

declaredLength

private int declaredLength

isModified

private boolean isModified

declaredContentType

private String declaredContentType
Constructor Detail

BufferedResponse

public BufferedResponse(HttpServletResponse response)
                 throws IOException

Constructs a new BufferedResponse, wrapping the response passed.

Parameters:
response - The original response from the filter chain..
Method Detail

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws IOException

Returns a OutputStream to the memory buffer.

IOException

getWriter

public PrintWriter getWriter()
                      throws IOException

Returns a PrintWriter to the memory buffer.

IOException

getData

public InputStream getData()
                    throws IOException

Returns a InputStream with the data currently stored in the memory buffer..

IOException

setContentLength

public void setContentLength(int length)

Does not let the content length be set, but stores it in a variable in case it is needed later.


getDeclaredLength

public int getDeclaredLength()

Returns the content length declared by the called resource.


setContentType

public void setContentType(String type)

Does not let the content type be set, but stores it in a variable in case it is needed later.


getDeclaredContentType

public String getDeclaredContentType()
Returns the content type declared by the called resource.


setStatus

public void setStatus(int sc)

If the status set if SC_NOT_MODIFIED, sets a flag so that the output filter knows that the buffer may be empty. This is to prevent errors when a static resource is wrapped by the filter and the containers returns an empty buffer if the resource has not been modified.


isModified

public boolean isModified()
Says if the resource called has been modified or not.


flushBuffer

public void flushBuffer()
                 throws IOException
Filters calls to flushBuffer() so that no data is written to the response before executing the output filter.

IOException