|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.ServletResponseWrapper
javax.servlet.http.HttpServletResponseWrapper
org.rakeshv.filters.CompressionResponseWrapper
public class CompressionResponseWrapper
A HttpServletResponseWrapper class that is used to
create a compressed output stream. This class
over-rides appropriate methods in the parent class to create
compressed OutputStreams and PrintWriters.
Note: - It is REQUIRED that you set the value of
the compressionType instance variable using the mutator
method setCompressionType( int ) if the compression is
to work.
© Copyright 2003, Rakesh Vidyadharan
| Field Summary | |
|---|---|
protected int |
compressionType
An integer that indicates the type of compression that is to be used. |
protected javax.servlet.http.HttpServletResponse |
servletResponse
Original response |
protected javax.servlet.ServletOutputStream |
stream
The ServletOutputStream that has been returned by
getOutputStream(), if any. |
protected java.io.PrintWriter |
writer
The PrintWriter that has been returned by getWriter(), if any. |
| Fields inherited from interface javax.servlet.http.HttpServletResponse |
|---|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY |
| Constructor Summary | |
|---|---|
CompressionResponseWrapper(javax.servlet.http.HttpServletResponse response)
Constructs a compressed response adaptor wrapping the given response. |
|
| Method Summary | |
|---|---|
javax.servlet.ServletOutputStream |
createOutputStream()
Create a new instance of the CompressionResponseWrapper
class, that compresses the response. |
void |
finish()
Finishes writing compressed data to the CompressionResponseStream output stream without
closing the underlying stream. |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
int |
getCompressionType()
Returns compressionType. |
javax.servlet.ServletOutputStream |
getOutputStream()
Returns a ServletOutputStream suitable for writing binary data in the response. |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter object that can send character text to the client. |
void |
setCompressionType(int compressionType)
Set compressionType. |
| Methods inherited from class javax.servlet.http.HttpServletResponseWrapper |
|---|
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus |
| Methods inherited from class javax.servlet.ServletResponseWrapper |
|---|
getBufferSize, getCharacterEncoding, getContentType, getLocale, getResponse, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale, setResponse |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.ServletResponse |
|---|
getBufferSize, getCharacterEncoding, getContentType, getLocale, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale |
| Field Detail |
|---|
protected javax.servlet.http.HttpServletResponse servletResponse
protected javax.servlet.ServletOutputStream stream
ServletOutputStream that has been returned by
getOutputStream(), if any.
protected java.io.PrintWriter writer
protected int compressionType
java.util.zip package.
| Constructor Detail |
|---|
public CompressionResponseWrapper(javax.servlet.http.HttpServletResponse response)
throws java.lang.IllegalArgumentException
super-class constructor, and
set the servletResponse reference.
response - - The response that is to
be compressed.
java.lang.IllegalArgumentException - - If the specified response is
null.| Method Detail |
|---|
public javax.servlet.ServletOutputStream createOutputStream()
throws java.io.IOException
CompressionResponseWrapper
class, that compresses the response.
DeflaterOutputStream
.
java.io.IOException - - If exceptions are encountered while
creating the compressed response stream.
public void flushBuffer()
throws java.io.IOException
flushBuffer in interface javax.servlet.ServletResponseflushBuffer in class javax.servlet.ServletResponseWrapperjava.io.IOException
public javax.servlet.ServletOutputStream getOutputStream()
throws java.io.IOException
Writer has not already been
created for the response (through a call to getWriter()
method) a new instance of the CompressionResponseStream
is created, and the instance variable stream set to the
new instance created. If the stream has already been
initialised, then the reference is returned.
getOutputStream in interface javax.servlet.ServletResponsegetOutputStream in class javax.servlet.ServletResponseWrapperjava.io.IOException - - If errors are encountered while creating
the compressed response stream.
java.lang.IllegalStateException - - If getWriter() has
already been called on this instance.
public java.io.PrintWriter getWriter()
throws java.io.IOException
CompressionResponseStream class. The character encoding
used is the one specified in the charset= property of the
setContentType( java.lang.String ) method, which must
be called before calling this method for the charset to take
effect.
If necessary, the MIME type of the response is modified to reflect the character encoding used.
Either this method or getOutputStream() may be called
to write the body, not both.
getWriter in interface javax.servlet.ServletResponsegetWriter in class javax.servlet.ServletResponseWrapperjava.io.IOException - - If errors are encountered while creating
the compressed response stream.
java.lang.IllegalStateException - - If getWriter() has
already been called on this instance.
public void finish()
throws java.io.IOException
CompressionResponseStream output stream without
closing the underlying stream.
Note: This method must be invoked by to properly finish the output if multiple filters are added in succession to the same output stream. This is generally the case, and hence this method must be called in order for the response to be completely sent back to the client.
java.io.IOException - - If errors are encountered while writing
to the stream. An exception will be thrown if this method is
invoked after the stream has been closed.public final int getCompressionType()
compressionType.
public final void setCompressionType(int compressionType)
compressionType.
compressionType - - The value to set.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||