Name

JspWriter

Synopsis

This is a Writer subclass that is available to JSP pages as the out variable. JspWriter behaves like a cross between a PrintWriter and a BufferedWriter, providing print() and println() methods and optional buffering. The initial JspWriter associated with a JSP request will be associated with a PrintWriter leading back to the client. JSP custom tags will have JspWriter’s that are associated with parent JSP Writers. This means that the page level settings for a JspWriter’s behavior will control the overall relationship of the JSP page with the client.

By default, a JspWriter will be buffered in auto-flush mode. The buffer size can be retrieved by getBufferSize() and the number bytes remaining in the buffer can be retrieved via the getRemaining() method. The isAutoFlush() method indicates whether the buffer will flush automatically when it is filled. The autoFlush page directive determines whether or not automatic flushing is enabled. After the buffer has been flushed, either by auto-flushing or by the flush() method, methods that manipulate response headers (such as HttpServletResponse.setContentType()) may not be called.

                  
public abstract class JspWriter extends Writer {
// Protected Constructors
   protected JspWriter( int bufferSize, boolean autoFlush);  
// Public Constants
   public static final int DEFAULT_BUFFER;                       // =-1
   public static final int NO_BUFFER;                            // =0

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.