Expression Language 2.0
Lenguaje de expresión utilizado principalmente en los JSP para acceder a información de los Java Beans, que pueden estar en algún Ambiente(Aplicación, Sesión, Petición o Página),Se utilizan como atributos de Etiquetas JSP.
<c:if test="${sessionScope.cart.numberOfItems > 0}"> ... </c:if>
<c:if test="${a.nombre == 'Juan'}" > ... </c:if>Variables
Objetos Implícitos
The JSP expression language defines a set of implicit objects:
pageContext
: The context for the JSP page. Provides access to various objects including:
servletContext
: The context for the JSP page's servlet and any web components contained in the same application. See Accessing the Web Context.
session
: The session object for the client. See Maintaining Client State.
request
: The request triggering the execution of the JSP page. See Getting Information from Requests.
response
: The response returned by the JSP page. See Constructing Responses. In addition, several implicit objects are available that allow easy access to the following objects:
param
: Maps a request parameter name to a single value
paramValues
: Maps a request parameter name to an array of values
header
: Maps a request header name to a single value
headerValues
: Maps a request header name to an array of values
cookie
: Maps a cookie name to a single cookie
initParam
: Maps a context initialization parameter name to a single valueFinally, there are objects that allow access to the various scoped variables described in Using Scope Objects.Literales
The JSP expression language defines the following literals:
- Boolean:
true
andfalse
- Integer: as in Java
- Floating point: as in Java
- String: with single and double quotes;
"
is escaped as\"
, 'is escaped as
\
', and\
is escaped as\\
.
- Null:
null
Operators
In addition to the.
and[]
operators discussed in Variables, the JSP expression language provides the following operators:
- Arithmetic:
+
,-
(binary),*
,/
anddiv
,%
andmod
,-
(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 isnull
or empty.
- Conditional:
A ? B : C
. EvaluateB
orC
, depending on the result of the evaluation ofA
. 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.and eq gt true instanceof or ne le false empty not lt ge null div mod
No hay comentarios:
Publicar un comentario