Java Reference
In-Depth Information
Expression Language 3.0
The Expression Language 3.0 Specification was developed under JSR 341. This sec-
tion gives you only an overview of improvement in the API. The complete document
specification (for more information) can be downloaded from
http://jcp.org/aboutJava/
What is Expression Language?
Expression Language
(
EL
) is a language used to access and manipulate data in
your JSP or JSF web pages. It provides a simple way to:
• Read/write data from/to JavaBean component properties
• Invoke static and public methods
• Perform arithmetic, relational, logical, and conditional operations
An EL expression looks like
${expr}
or
#{expr}
. The former syntax is often used
for immediate evaluation while the latter is used for deferred evaluation. The following
code demonstrates how to access a JSF bean property from a JSF page and how to
perform an operation between two integers using EL expressions:
<h:form>
<h:outputText
id="beanProperty"
value="Bean property value :
#{studentBean.identity}" />
<br/>
<h:outputText
id="operator"
value="operator : 3 + 12 = #{3 + 12}" />
</h:form>
The latest improvements of EL 3.0 in action
EL was first designed for
JSP Standard Tag Library
(
JSTL
), before being associated
withtheJSP Specification andthentotheJSF Specification. Since bothspecifications
had different needs at the onset, each specification used a variant of the EL. The ad-