Appendix B. JSP Expression Language Reference

This appendix captures, at one location, the syntactical details of the Expression Language (EL) in JSP 2. It serves as a quick reference for resolving usage questions as you apply EL in your JSP programs.

EL Expressions

EL is a language that complements JSTL, enabling the creation of completely scriptless JSPs. As its name implies, EL is a language that revolves around the evaluation of expressions. EL expressions provide powerful access to JavaBeans, Java collections, Java maps, and Java arrays. This capability eliminates the need to perform access through Java coding from within scripting elements. An EL expression is always dynamically evaluated at request time. All EL expressions are contained in the following notation:

${.... EL expression..... }

El expressions may appear in two distinct locations in a JSP page:

  • In-line with template data

  • Within attribute values of tags (for example, JSTL tags)

EL expressions in-line with template data

An EL expression can be used to render a textual string in-line with template data—for example, as a constant EL arithmetic expression:

<b>There are ${5 + 1} bears in the cave.</b>

Another example demonstrates the use of EL to address a property of a nested JavaBeans:

<b>The total cost for this order is ${order.totals.afterTax}.</b>

EL expressions in attribute values

EL expressions are also used for the attribute values of certain tags. Namely, EL expressions are frequently found in the attribute values of tags ...

Get Beginning JavaServer Pages™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.