background image

Deactivating Expression Evaluation

<< Defining aTag AttributeType | Literal Expressions >>
<< Defining aTag AttributeType | Literal Expressions >>

Deactivating Expression Evaluation

TABLE 5­2
Definitions of Tag Attributes That Accept EL Expressions
(Continued)
Attribute Type
Example Expression
Type Attribute Definition
deferred value
"literal"
<deferred-value>
<type>java.lang.String</type>
</deferred-value>
#{customer.age}
<deferred-value>
<type>int</type>
</deferred-value>
deferred method
"literal"
<deferred-method>
<method-signature>
java.lang.String submit()
</method-signature>
<deferred-method>
#{customer.calcTotal}
<deferred-method>
<method-signature>
double calcTotal(int, double)
</method-signature>
</deferred-method>
In addition to the tag attribute types shown in
Table 5­2
, you can also define an attribute to
accept both dynamic and deferred expressions. In this case, the tag attribute definition contains
both an rtexprvalue definition set to true and either a deferred-value or deferred-method
definition.
Deactivating Expression Evaluation
Because the patterns that identify EL expressions, ${ } and #{ }, were not reserved in the JSP
specifications before JSP 2.0, there might exist applications in which such patterns are intended
to pass through verbatim. To prevent the patterns from being evaluated, you can deactivate EL
evaluation using one of the following methods:
Escape the #{ or ${ characters in the page.
Configure the application with a JSP Property Group.
Configure the page with the page directive.
To escape the #{ or ${ characters in the page, you use the \ character as follows:
some text \#{ some more\${ text
<my:tag someAttribute=
"sometext\#{more\${text" />
Another way to deactivate EL evaluation is by using a JSP property group to either allow the #{
characters as a String literal using the deferred-syntax-allowed-as-literal subelement, or
to treat all expressions as literals using the el-ignored subelement:
Unified Expression Language
Chapter 5 · JavaServer Pages Technology
157