org.blojsom.filter
Class GZIPResponseStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjavax.servlet.ServletOutputStream
          extended byorg.blojsom.filter.GZIPResponseStream

public class GZIPResponseStream
extends javax.servlet.ServletOutputStream

GZIPResponseStream

Copyright 2003 Jayson Falkner (jayson@jspinsider.com) This code is from "Servlets and JavaServer pages; the J2EE Web Tier", http://www.jspbook.com. You may freely use the code both commercially and non-commercially. If you like the code, please pick up a copy of the book and help support the authors, development of more free code, and the JSP/Servlet/J2EE community.

Since:
blojsom 2.10
Version:
$Id: GZIPResponseStream.java,v 1.7 2006/01/04 16:59:54 czarneckid Exp $

Field Summary
protected  java.io.ByteArrayOutputStream baos
           
protected  boolean closed
           
protected  java.util.zip.GZIPOutputStream gzipstream
           
protected  javax.servlet.ServletOutputStream output
           
protected  javax.servlet.http.HttpServletResponse response
           
 
Constructor Summary
GZIPResponseStream(javax.servlet.http.HttpServletResponse response)
          Create a new GZIPResponseStream
 
Method Summary
 void close()
          Close this response stream
 boolean closed()
          Returns true if the stream is closed, false otherwise
 void flush()
          Flush the response stream
 void reset()
          Reset the stream.
 void write(byte[] b)
          Write a byte array to the stream
 void write(byte[] b, int off, int len)
          Write a byte array to the stream
 void write(int b)
          Write a byte to the stream
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baos

protected java.io.ByteArrayOutputStream baos

gzipstream

protected java.util.zip.GZIPOutputStream gzipstream

closed

protected boolean closed

response

protected javax.servlet.http.HttpServletResponse response

output

protected javax.servlet.ServletOutputStream output
Constructor Detail

GZIPResponseStream

public GZIPResponseStream(javax.servlet.http.HttpServletResponse response)
                   throws java.io.IOException
Create a new GZIPResponseStream

Parameters:
response - Original HTTP servlet response
Throws:
java.io.IOException - If there is an error creating the response stream
Method Detail

close

public void close()
           throws java.io.IOException
Close this response stream

Throws:
java.io.IOException - If the stream is already closed or there is an error closing the stream

flush

public void flush()
           throws java.io.IOException
Flush the response stream

Throws:
java.io.IOException - If the stream is already closed or there is an error flushing the stream

write

public void write(int b)
           throws java.io.IOException
Write a byte to the stream

Parameters:
b - Byte to write
Throws:
java.io.IOException - If the stream is closed or there is an error in writing

write

public void write(byte[] b)
           throws java.io.IOException
Write a byte array to the stream

Parameters:
b - Byte array to write
Throws:
java.io.IOException - If the stream is closed or there is an error in writing

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write a byte array to the stream

Parameters:
b - Byte array to write
off - Offset of starting point in byte array to start writing
len - Length of bytes to write
Throws:
java.io.IOException - If the stream is closed or there is an error in writing

closed

public boolean closed()
Returns true if the stream is closed, false otherwise

Returns:
true if the stream is closed, false otherwise

reset

public void reset()
Reset the stream. Currently a no-op.