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.

Using Scripting<br />

Disabling Scripting<br />

JSP technology allows a container to support any scripting language that can call <strong>Java</strong> objects. If<br />

you wish to use a scripting language other than the default, java, you must specify it in the<br />

language attribute of the page directive at the beginning of a JSP page:<br />

<br />

Because scripting elements are converted to programming language statements in the JSP<br />

page’s servlet class, you must import any classes and packages used by a JSP page. If the page<br />

language is java, you import a class or package with the import attribute of the page directive:<br />

<br />

<strong>The</strong> webclient JSP page response.jsp uses the following page directive to import the classes<br />

needed to access the service classes:<br />

<br />

By default, scripting in JSP pages is valid. Because scripting can make pages difficult to<br />

maintain, some JSP page authors or page authoring groups may want to follow a methodology<br />

in which scripting elements are not allowed.<br />

You can disable scripting for a group of JSP pages in an application in one of two ways:<br />

■ Select the Ignore <strong>Java</strong> Script check box in the JSP Property Group node of the NetBeans IDE<br />

web.xml editor.<br />

■ Set the scripting-invalid element of the application’s deployment descriptor to true. <strong>The</strong><br />

scripting-invalid element is a child of the jsp-property-group element that defines<br />

properties for a set of JSP pages.<br />

For information on how to define a group of JSP pages, see “Setting Properties for Groups of JSP<br />

Pages” on page 177. When scripting is invalid, it means that scriptlets, scripting expressions,<br />

and declarations will produce a translation error if present in any of the pages in the group.<br />

Table 9–1 summarizes the scripting settings and their meanings.<br />

TABLE 9–1 Scripting Settings<br />

JSP Configuration Scripting Encountered<br />

Unspecified Valid<br />

Disabling Scripting<br />

Chapter 9 • Scripting in JSP Pages 273

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

Saved successfully!

Ooh no, something went wrong!