|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.OutputStream | +--com.primix.tapestry.ResponseOutputStream
A special output stream works with a HttpServletResponse
, buffering
data so as to defer opening the response's output stream.
A ResponseOutputStream
must be closed specially, using
forceClose()
. Otherwise, it ignores close()
, because
of unwanted chaining of close()
from outer writers and streams.
The buffering is pretty simple because the code
between IResponseWriter
and this shows lots of buffering
after the PrintWriter
and inside the OutputStreamWriter
that
can't be configured.
Possibly, this needs to be rethunk. Perhaps we need a ResponseWriter
class instead that could trap the output characters before they get into the PrintWriter
and its crew. This would save on the number of conversions between characters and
bytes.
In fact, this is now even less useful, because the
Body
component (which will
be used on virtually all Tapestry pages), buffers its wrapped contents
(that is, evertyhing inside the <body> tag in the generated HTML).
Field Summary | |
static int |
DEFAULT_SIZE
Default size for the buffer (2000 bytes). |
Constructor Summary | |
ResponseOutputStream(HttpServletResponse response)
Creates the stream with the default maximum buffer size. |
|
ResponseOutputStream(HttpServletResponse response,
int maxSize)
Standard constructor. |
Method Summary | |
void |
close()
Does nothing. |
void |
flush()
Flushes the underlying output stream, if is has been opened. |
void |
forceClose()
Flushes the internal buffer to the underlying output stream, then closes the underlying output stream. |
void |
forceFlush()
Writes the internal buffer to the output stream, opening it if necessary, then flushes the output stream. |
java.lang.String |
getContentType()
|
boolean |
getDiscard()
|
void |
reset()
Discards all output in the buffer. |
void |
setBufferSize(int value)
Changes the maximum buffer size. |
void |
setContentType(java.lang.String value)
|
void |
setDiscard(boolean value)
Indicates whether the stream should ignore all data written to it. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_SIZE
Constructor Detail |
public ResponseOutputStream(HttpServletResponse response)
public ResponseOutputStream(HttpServletResponse response, int maxSize)
Method Detail |
public void close() throws java.io.IOException
close()
from
IResponseWriter.close()
... see flush()
.close
in class java.io.OutputStream
public void flush() throws java.io.IOException
This method explicitly does not flush the internal buffer ...
that's because when an IResponseWriter
is closed (for instance, because
an exception is thrown), that close()
spawns flush()
es
and close()
s throughout the output stream chain, eventually
reaching this method.
flush
in class java.io.OutputStream
forceFlush()
,
forceClose()
public void forceClose() throws java.io.IOException
setContentLength()
is invoked on the HttpServletResponse
... this allows the web server and client to use Keep-Alive connections.
In rare instances (such as sending a HTTP redirect),
the ReponseOutputStream
is closed
when no data has been written to it. In that case, we never
invoke HttpServletResponse.getOutputStream()
.
public void forceFlush() throws java.io.IOException
public java.lang.String getContentType()
public boolean getDiscard()
public void reset() throws java.io.IOException
Clears the discard flag.
public void setBufferSize(int value) throws java.io.IOException
public void setContentType(java.lang.String value)
public void setDiscard(boolean value)
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |