O'Reilly logo

JavaServer Pages, Second Edition by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required