com.mortbay.HTTP
Class HttpOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--javax.servlet.ServletOutputStream
              |
              +--com.mortbay.HTTP.HttpOutputStream

public class HttpOutputStream
extends javax.servlet.ServletOutputStream

HTTP output stream

Implements ServletOutputStream

Notes

Implements a callback to the HttpResponse to trigger a writeHeader on the first output. Not if HttpFilters are used, this may result in replaceOut being called on this HttpOutputStream.

The path that a single call to write on HttpOutputStream can be delegated to the following output streams:

  ---> HttpOutputSteam.out --> Filter out 1 --> ... -> Filter out N
                                                               |
             HttpOutputStream$SwitchedOutStream switchOut <----+
                                   /     \
                                  /       \
                                 V         V
 socket <---  HttpOutputStream.realOut <-- ByteArrayOutputStream chunk

 

Version:
$Id: HttpOutputStream.java,v 2.4 1999/09/22 15:08:42 gregw Exp $
Author:
Greg Wilkins

Constructor Summary
HttpOutputStream(java.io.OutputStream out, HttpResponse response)
           
 
Method Summary
 void close()
           
 void flush()
           
 java.io.OutputStream getOutputStream()
           
 void print(int i)
          Writes an integer to the client, with no carriage return-line feed (CRLF) character at the end.
 void print(long i)
          Writes a long value to the client, with no carriage return-line feed (CRLF) character at the end.
 void print(java.lang.String string)
          Writes a String to the client, without a carriage return-line feed (CRLF) character at the end.
 void println()
          Writes a carriage return-line feed (CRLF) character to the client.
 void println(int i)
          Writes an integer to the client, followed by a carriage return-line feed (CRLF) character.
 void println(long i)
          Writes a long value to the client, followed by a carriage return-line feed (CRLF) character.
 void println(java.lang.String string)
          Writes a String to the client, followed by a carriage return-line feed (CRLF) character.
 java.io.OutputStream replaceOutputStream(java.io.OutputStream newOut)
           
 void setChunking(boolean on)
          Switch chunking on an off
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, println, println, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpOutputStream

public HttpOutputStream(java.io.OutputStream out,
                        HttpResponse response)
Method Detail

getOutputStream

public java.io.OutputStream getOutputStream()

replaceOutputStream

public java.io.OutputStream replaceOutputStream(java.io.OutputStream newOut)

setChunking

public void setChunking(boolean on)
                 throws java.io.IOException
Switch chunking on an off
Parameters:
on -  

write

public void write(int b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream

flush

public void flush()
           throws java.io.IOException
Overrides:
flush in class java.io.OutputStream

close

public void close()
           throws java.io.IOException
Overrides:
close in class java.io.OutputStream

print

public void print(java.lang.String string)
           throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes a String to the client, without a carriage return-line feed (CRLF) character at the end.
Overrides:
print in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Parameters:
s - the StringThrows:
java.io.IOException - if an input or output exception occurred

print

public void print(int i)
           throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes an integer to the client, with no carriage return-line feed (CRLF) character at the end.
Overrides:
print in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Parameters:
i - the integer to send to the client
Throws:
java.io.IOException - if an input or output exception occurred

print

public void print(long i)
           throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes a long value to the client, with no carriage return-line feed (CRLF) character at the end.
Overrides:
print in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Parameters:
l - the long value to send to the client
Throws:
java.io.IOException - if an input or output exception occurred

println

public void println(java.lang.String string)
             throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes a String to the client, followed by a carriage return-line feed (CRLF) character.
Overrides:
println in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Parameters:
s - the String to write to the client
Throws:
java.io.IOException - if an input or output exception occurred

println

public void println(int i)
             throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes an integer to the client, followed by a carriage return-line feed (CRLF) character.
Overrides:
println in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Parameters:
i - the integer to write to the client
Throws:
java.io.IOException - if an input or output exception occurred

println

public void println(long i)
             throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes a long value to the client, followed by a carriage return-line feed (CRLF) character.
Overrides:
println in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Parameters:
l - the long value to write to the client
Throws:
java.io.IOException - if an input or output exception occurred

println

public void println()
             throws java.io.IOException
Description copied from class: javax.servlet.ServletOutputStream
Writes a carriage return-line feed (CRLF) character to the client.
Overrides:
println in class javax.servlet.ServletOutputStream
Tags copied from class: javax.servlet.ServletOutputStream
Throws:
java.io.IOException - if an input or output exception occurred