Web Development with JavaServer Pages

Скачать в pdf «Web Development with JavaServer Pages»


Each character of static text in the original JSP page will of course translate into one character’s worth of data in the final output. For dynamically generated content, a conservative approach is to estimate the maximum number of characters corresponding to each JSP element which generates output. After summing all of these character counts, multiply by the number of bytes per character to compute the required buffer size, dividing by 1,024 to convert bytes into kilobytes. You will likely find that the default value of 8 KB is sufficient for most JSP pages, but pages which generate significant amounts of dynamic content may need correspondingly larger output buffers.

AutoFlush attribute


This attribute is also used for controlling buffered output. In particular, this attribute controls the behavior of the JSP container when the page’s output buffer becomes full. If this attribute is set to true (the default), the output buffer will automatically be flushed, and its current contents sent to the HTTP server for transmission to the requesting web browser. Page processing then resumes, with any and all new content being buffered until the buffer once again becomes full, or the end of the page is reached. This attribute is set as follows:


<%@ page autoFlush=»true» %>


As mentioned in chapter 4, note that once the buffer has been flushed and its initial contents sent to the browser, it is no longer possible for the JSP page to set response headers or forward processing to a different JSP page.


If autoFlush is set to false, the JSP container will not automatically flush the buffer when it becomes full. Instead, it will raise an exception, which will have the effect of halting processing of the JSP page and displaying an error page in the browser that originally requested the page. The class of the exception raised under these circumstances is implementation-specific. Also, keep in mind that it is illegal to set the autoflush attribute to false when the buffer attribute is set to none. In other words, the JSP container cannot be set to signal an exception when the output buffer becomes full if there is no output buffer in the first place.

Скачать в pdf «Web Development with JavaServer Pages»