background image

Operators

<< Implicit Objects | Examples of EL Expressions >>
<< Implicit Objects | Examples of EL Expressions >>

Operators

expression ${product}, the resolver will look for product in the page, request, session, and
application scopes and will return its value. If product is not found, null is returned.
When an expression references one of the implicit objects by name, the appropriate object is
returned instead of the corresponding attribute. For example, ${pageContext} returns the
PageContext
object, even if there is an existing pageContext attribute containing some other
value.
Operators
In addition to the . and [] operators discussed in
"Value and Method Expressions" on
page 150
, the JSP expression language provides the following operators, which can be used in
rvalue expressions only:
Arithmetic
: +, - (binary), *, / and div, % and mod, - (unary)
Logical
: and, &&, or, ||, not, !
Relational
: ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le. Comparisons can be made against other
values, or against boolean, string, integer, or floating point literals.
Empty
: The empty operator is a prefix operation that can be used to determine whether a
value is null or empty.
Conditional
: A ? B : C. Evaluate B or C, depending on the result of the evaluation of A.
The precedence of operators highest to lowest, left to right is as follows:
[] .
()
(used to change the precedence of operators)
-
(unary) not ! empty
* / div % mod
+ -
(binary)
< > <= >= lt gt le ge
== != eq ne
&& and
|| or
? :
Reserved Words
The following words are reserved for the JSP expression language and should not be used as
identifiers.
Unified Expression Language
Chapter 5 · JavaServer Pages Technology
163