Web Development with JavaServer Pages

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

If the exception is thrown, however, then the clearBuffer() method is called on the out object. This will have the effect of discarding any content that has been generated since the last time the output buffer was flushed. In this particular case, the output buffer was flushed just before opening the try block. Therefore, only the content generated by the try block before the exception occurred would be in the output buffer, so only that content will be removed when the output buffer is

cleared. The output buffer will then be overwritten with the error message indicating that the argument was out of range.

WARNING There is, of course, a down side to this approach. Recall from the discussion of buffered output in chapter 4, that once the output buffer has been flushed, it is no longer possible to change or add response headers, or forward to another page. The call to the flush() method at the beginning of this page fragment thus limits your options for processing the remainder of the page.

6.1.3 Contextual objects

The implicit objects in this category provide the JSP page with access to the context within which it is being processed. The session object, for example, provides the context for the request to which the page is responding. What data has already been associated with the individual user who is requesting the page? The application object provides the server-side context within which the page is running. What other resources are available, and how can they be accessed? In contrast, the page-Context object is focused on the context of the JSP page itself, providing programmatic access to all of the other JSP implicit objects which are available to the page, and managing their attributes.

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