Both approaches are valid, and thus both are supported in the JSP technology. The behavior 
of a page is controlled by the 
 attribute, which defaults to true. In general, JSP 
pages that need to be sure that correct and complete data has been sent to their client may 
want to set 
, with a typical case being that where the client is an 
application itself. On the other hand, JSP pages that send data that is meaningful even when 
partially constructed may want to set 
; a case may be when the data is 
sent for immediate display through a browser. Each application will need to consider their 
specific needs.
An alternative considered was to make the buffer size unbounded, but this has the 
disadvantage that runaway computations may consume an unbounded amount of resources.
 interface includes behaviors from
 API's but incorporates buffering and does not consume 
IOExceptions as PrintWriter does. If a particular use requires a PrintWriter, as in the case of 
desiring to insert an exception stack trace, one can be obtained by wrapping the JspWriter 
with a PrintWriter.
The usual methods found in PrintWriter are available with the only modification being that 
the JspWriter methods do not consume IOExceptions. The additional methods are:
This method is used to clear the buffer of data. It is illegal to invoke it if the JspWriter 
is not buffered. And exception will be raised if the buffer has been autoFlushed and 
clear() is invoked. Also see clearBuffer().
The method signature is 
void clear()
This method is like clear() except that no exception will be raised if the buffer has been 
The method signature is 
void clearBuffer()
This method is used to flush the buffer of data. The method may be invoked indirectly 
if the buffer size is exceeded. The underlying PrintWriter object is guaranteed to be 
created exactly the first time data is flushed to it.
The method signature is 
void flush()
This method can be used to close the stream. It needs not be invoked explicitly for the 
initial JspWriter as the code generated by the JSP container will automatically include 
a call to close().
The method signatures is 
void close().
This method returns the size of the buffer used by the JspWriter.
The method signatures is 
int getBufferSize()
This method returns the number of unused bytes in the buffer.
The method signature is 
int getRemaining()
Appendix 6
JSP Technology Classes

JSP Web Hosting JavaServer Pages Specifications JSP Hosting Business web hosting division of Vision Web Hosting Inc. All rights reserved.