0% found this document useful (0 votes)
35 views

Expression Language

The document discusses expression language, which allows accessing JavaBean property values in JSPs using a simpler syntax like ${item.price}. It is based on SPEL from JSTL 1.0 and is recognized in JSP template text and custom action attributes. Custom EL functions can also be used, and JSTL 1.1 provides 16 standard functions like ${fn:allCaps(lastName)}. Examples show how scriptlets can be replaced with equivalent EL expressions to access bean properties and maps.

Uploaded by

duongtuanvn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Expression Language

The document discusses expression language, which allows accessing JavaBean property values in JSPs using a simpler syntax like ${item.price}. It is based on SPEL from JSTL 1.0 and is recognized in JSP template text and custom action attributes. Custom EL functions can also be used, and JSTL 1.1 provides 16 standard functions like ${fn:allCaps(lastName)}. Examples show how scriptlets can be replaced with equivalent EL expressions to access bean properties and maps.

Uploaded by

duongtuanvn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Expression Language

1
Expression Language
● Based on “SPEL” from JSTL 1.0
– Simplest Possible Expression Language
● Let you access the property values of a
JavaBean in a simpler syntax
– Example: ${item.price}
● Recognized by JSP container in:
– Template text
– Attributes of any standard or custom action
● Support for custom EL functions:
– Extensible via tag libraries
– Example: ${fn:allCaps(lastName)}
– JSTL 1.1 provides 16 standard EL functions
2
Integrated Expression
Language Example
● Using scriptlets:
<center>
<jsp:useBean id="foo" class="FooBean" />
<%= foo.getBar() %>
</center>

● Equivalent, using an EL expression:


<center>
${foo.bar}
</center>
3
Integrated Expression
Language Example
● Using scriptlets:
<% Map m = (Map)pageContext.getAttribute("states" );
State s = ((State)m.get( "NY" ));
if( s != null ) {
%>
<%= s.getCapitol() %>
<% } %>

● Equivalent, using an EL expression:


${states["NY"].capitol}
${states["NY"].capitol.name}
4

You might also like