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.

Unified Expression Language<br />

156<br />

they accept and the type definitions of the attributes that must be added to the TLD. You cannot<br />

use #{} syntax for a dynamic attribute, meaning an attribute that accepts<br />

dynamically-calculated values at runtime. Section 2.3.2 of the <strong>Java</strong>Server Pages 2.1 specification<br />

refers to these attributes. Neither can you use the ${} syntax for a deferred attribute.<br />

TABLE 5–2 Definitions of Tag Attributes That Accept EL Expressions<br />

AttributeType Example Expression Type Attribute Definition<br />

dynamic "literal" true<br />

${literal} true<br />

deferred value "literal" <br />

java.lang.String<br />

<br />

#{customer.age} <br />

int<br />

<br />

deferred method "literal" <br />

<br />

java.lang.String submit()<br />

<br />

<br />

#{customer.calcTotal} <br />

<br />

double calcTotal(int, double)<br />

<br />

<br />

In addition to the tag attribute types shown in Table 5–2, you can also define an attribute to<br />

accept both dynamic and deferred expressions. In this case, the tag attribute definition contains<br />

both an rtexprvalue definition set to true and either a deferred-value or deferred-method<br />

definition.<br />

Deactivating Expression Evaluation<br />

Because the patterns that identify EL expressions, ${ } and #{ }, were not reserved in the JSP<br />

specifications before JSP 2.0, there might exist applications in which such patterns are intended<br />

to pass through verbatim. To prevent the patterns from being evaluated, you can deactivate EL<br />

evaluation using one of the following methods:<br />

■ Escape the #{ or ${ characters in the page.<br />

■ Configure the application with a JSP Property Group.<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!