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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

JSP Declarations<br />

JSP Declarations<br />

274<br />

TABLE 9–1 Scripting Settings (Continued)<br />

JSP Configuration Scripting Encountered<br />

false Valid<br />

true Translation Error<br />

A JSP declaration is used to declare variables and methods in a page’s scripting language. <strong>The</strong><br />

syntax for a declaration is as follows:<br />

<br />

When the scripting language is the <strong>Java</strong> programming language, variables and methods in JSP<br />

declarations become declarations in the JSP page’s servlet class.<br />

Initializing and Finalizing a JSP Page<br />

You can customize the initialization process to allow the JSP page to read persistent<br />

configuration data, initialize resources, and perform any other one-time activities; to do so, you<br />

override the jspInit method of the JspPage interface. You release resources using the<br />

jspDestroy method. <strong>The</strong> methods are defined using JSP declarations.<br />

For example, an older version of the Duke’s Bookstore application retrieved the object that<br />

accesses the bookstore database from the context and stored a reference to the object in the<br />

variable bookDBAO in the jspInit method. <strong>The</strong> variable definition and the initialization and<br />

finalization methods jspInit and jspDestroy were defined in a declaration:<br />

<br />

When the JSP page was removed from service, the jspDestroy method released the BookDBAO<br />

variable.<br />

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

Saved successfully!

Ooh no, something went wrong!