10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating Static Content<br />

<br />

This directive makes an object of type javax.servlet.jsp.ErrorData available to the error<br />

page so that you can retrieve, interpret, and possibly display information about the cause of the<br />

exception in the error page. You access the error data object in an EL (see “Unified Expression<br />

Language” on page 146) expression by way of the page context. Thus,<br />

${pageContext.errorData.statusCode} retrieves the status code, and<br />

${pageContext.errorData.throwable} retrieves the exception. You can retrieve the cause of<br />

the exception using this expression:<br />

${pageContext.errorData.throwable.cause}<br />

For example, the error page for Duke’s Bookstore is as follows:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

: ${pageContext.errorData.throwable.cause}<br />

<br />

<br />

Note – You can also define error pages for the WAR that contains a JSP page. If error pages are<br />

defined for both the WAR and a JSP page, the JSP page’s error page takes precedence.<br />

Creating Static Content<br />

144<br />

You create static content in a JSP page simply by writing it as if you were creating a page that<br />

consisted only of that content. Static content can be expressed in any text-based format, such as<br />

HTML, Wireless Markup Language (WML), and XML. <strong>The</strong> default format is HTML. If you<br />

want to use a format other than HTML, at the beginning of your JSP page you include a page<br />

directive with the contentType attribute set to the content type. <strong>The</strong> purpose of the<br />

contentType directive is to allow the browser to correctly interpret the resulting content. So if<br />

you wanted a page to contain data expressed in WML, you would include the following<br />

directive:<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!