All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class calypso.core.httpserver.HttpServletOutputStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----javax.servlet.ServletOutputStream
                   |
                   +----calypso.core.httpserver.HttpServletOutputStream

public class HttpServletOutputStream
extends ServletOutputStream
Implementation of ServletOutputStream to be used with HTTP servlets. Some methods of the ServletOutputStream class have been overridden to optimize performance.

It is possible to add one listener for this output stream. The listener will be notified when this stream is written for the first time after initialization (call to init method). For example a HTTP server can take benefit of this functionality. When this output stream is written for the first time after initialization, the HTTP server is notified and it can send HTTP headers before any actual data is written to the stream.

The reason for the restriction that only one listener can be attached to this output stream is efficiency and simplicity. At the moment there is no need to add more than one listener to a stream.

Version:
1.0
Author:
Juha Pääjärvi / TCM laboratory / Helsinki Univ. of Tech.
See Also:
HttpStreamListener, HttpStreamEvent

Constructor Index

 o HttpServletOutputStream()
Constructs an HttpServletOutputStream.

Method Index

 o addHttpStreamListener(HttpStreamListener)
Adds a listener to this HttpServletOutputStream.
 o close()
Closes this output stream.
 o flush()
Flushes this output stream and forces any buffered output bytes to be written out.
 o init(OutputStream)
Initializes this HttpServletOutputStream to write to the output stream specified as an argument.
 o print(char)
Prints the character given as an argument.
 o print(String)
Prints the string given as an argument.
 o println()
Prints a CRLF.
 o removeHttpStreamListener(HttpStreamListener)
Remove the specified listener from this stream.
 o write(byte[])
Writes an array of bytes to this output stream.
 o write(byte[], int, int)
Writes len bytes from the specified byte array starting at offset off to this output stream.
 o write(int)
Writes one byte to the output stream.

Constructors

 o HttpServletOutputStream
 public HttpServletOutputStream()
Constructs an HttpServletOutputStream.

Methods

 o init
 public void init(OutputStream output_)
Initializes this HttpServletOutputStream to write to the output stream specified as an argument.

Parameters:
output_ - the new destination for this HttpServletOutputStream.
 o addHttpStreamListener
 public synchronized void addHttpStreamListener(HttpStreamListener listener_) throws HttpServerException
Adds a listener to this HttpServletOutputStream. Note that it is possible to add only one listener to this stream. If there already exists a listener an exception is thrown.

Parameters:
listener_ - listener that wants to be notified.
Throws: HttpServerException
If this stream already has a listener.
 o removeHttpStreamListener
 public synchronized void removeHttpStreamListener(HttpStreamListener listener_) throws HttpServerException
Remove the specified listener from this stream.

Parameters:
listener_ - the listener to be removed.
Throws: HttpServerException
If the specified listener is not a listener for this stream.
 o print
 public final void print(String s_) throws IOException
Prints the string given as an argument.

Parameters:
s_ - string to be written.
Throws: IOException
If an I/O error occurs.
Overrides:
print in class ServletOutputStream
 o print
 public final void print(char c_) throws IOException
Prints the character given as an argument.

Parameters:
c_ - character to be written.
Throws: IOException
If an I/O error occurs.
Overrides:
print in class ServletOutputStream
 o println
 public final void println() throws IOException
Prints a CRLF.

Throws: IOException
If an I/O error occurs.
Overrides:
println in class ServletOutputStream
 o write
 public final void write(int i_) throws IOException
Writes one byte to the output stream.

Parameters:
i_ - value of the byte to write.
Throws: IOException
If an I/O error occurs.
Overrides:
write in class OutputStream
 o write
 public void write(byte b_[]) throws IOException
Writes an array of bytes to this output stream.

Parameters:
b_ - the array to be written.
Throws: IOException
If an I/O error occurs.
Overrides:
write in class OutputStream
 o write
 public final void write(byte b_[],
                         int off,
                         int len) throws IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws: IOException
If an I/O error occurs.
Overrides:
write in class OutputStream
 o flush
 public void flush() throws IOException
Flushes this output stream and forces any buffered output bytes to be written out.

Throws: IOException
if an I/O error occurs.
Overrides:
flush in class OutputStream
 o close
 public void close() throws IOException
Closes this output stream. This method does nothing, because it is not any business of servlets to close their output stream. In HTTP/1.1 persistent connections (keep-alive) it is default behaviour and servlets should not close their input and output streams, because there might be new requests coming that use the same connection.

Overrides:
close in class OutputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index