Expressions and Operators

The combination of literal values, variables and the following operators form an EL expression:

Operator

Precedence

Operation performed

.

1

Accesses a bean property or Map entry

[]

1

Accesses an array or List element

(  )

2

Groups a subexpression to change the evaluation order

+

5

Addition

-

5

Subtraction

-

3

Negation of a value

*

4

Multiplication

/ or div

4

Division

% or mod

4

Modulo (remainder)

== or eq

7

Tests for equality

!= or ne

7

Tests for inequality

< or lt

6

Tests for less than

> or gt

6

Tests for greater than

<= or le

6

Tests for less than or equal

>= or gt

6

Tests for greater than or equal

&& or and

8

Tests for logical AND

|| or or

9

Tests for logical OR

! or not

3

Unary Boolean complement

empty

3

Tests for empty variable values (null or an empty String, array, Map, or List)

Expressions are evaluated in the order defined by the operator precedence and left to right for operators of the same precedence.

Operand Coercing Rules

Before the operator is applied, the EL coerces the types of the operand values. An exception is thrown if no rule matches, the coercing fails or applying the operator leads to an exception.

Property and array accessor operators

An expression of the form ${exprA.identifierB} is evaluated the same way as ${exprA['identifierB'}.

To evaluate an expression of the form ${exprA[exprB]}, the following rules are used:

  • If exprA is null, return ...

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.