The buffer Attribute The buffer attribute specifies buffering characteristics for the server output response object. You d want a buffer for efficiency because buffered output is usually quicker than unbuffered output. Writing to the browser requires resources. The server sends buffered output in large blocks a few times, which requires less resources than sending unbuffered output in small blocks more often. You may code a value of “none” to specify no buffering so that all servlet output is immediately directed to the response object. You may code a maximum buffer size in kilobytes, which directs the servlet to write to the buffer before writing to the response object. Here are a few coding examples: To direct the servlet to write output directly to the response output object, use the following: <%@ page buffer="none" %> Use the following to direct the servlet to write output to a buffer of size not less than 8 kilobytes: <%@ page buffer="8kb" %> The exact size depends on the server. The behavior of the buffer when full is indicated by the value of the autoFlush attribute, which is described in the next section. The default value of the buffer attribute depends on the server implementation. The autoFlush Attribute The autoFlush attribute controls the behavior of the buffer or, more specifically, what happens to the output buffer when the JSP is buffered and the buffer is full (see the buffer attribute above). The autoFlush attribute takes a Boolean as a value. Some examples accompanied by a brief description of the directive follow. The following directive causes the servlet to throw an exception when the servlet s output buffer is full: <%@ page autoFlush="false"> This directive causes the servlet to flush the output buffer when full: <%@ page autoFlush="true"> Usually, the buffer and autoFlush attributes are coded on a single page directive as follows: <%@ page buffer="16kb" autoflush="true" %> The preceding directive establishes an output buffer not greater than 16 kilobytes that is flushed automatically when full. This directive generates an error. It doesn t make sense to code the autoFlush attribute without a buffer: <%@ page buffer="none" autoflush="false" %>
Do you want truly affordable web hosting? With us, what you see is what you get, just click on affordable web hosting services.

Leave a Reply