Buffer and AutoFlush

Intertech Tutorials

Buffer and AutoFlush

The buffer and autoFlush attributes to the page directive are related. In every JSP there is a buffer so HTML can be constructed. This is the buffer used by the “out” implicit object to handle output sent to the client. The buffer attribute indicates the buffer’s size in kilobytes. The default size is 8K. Use the page directive’s buffer size attribute to override the default buffer size.

<%@ page buffer=”12k” %>

When the buffer fills it automatically flushes the text down to the client (typically the browser). Use “none” as the value on the buffer attribute if the output should be immediately flushed to the client (with no buffering).

<%@ page buffer=”none” %>

Change the size of the buffer to achieve better performance. Using the autoFlush attribute on the page directive, you can stop the buffer from automatically flushing.

<%@ page autoFlush=”false” %>

By default, the buffer automatically flushes. When not automatically flushing, if the buffer fills it throws an exception instead allowing you, the developer, to manually flush it.

Copyright (c) 2008-2013. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.