Java Reference
In-Depth Information
vent of JSP 2.1 EL led to unification of the EL used in JSP and JSF pages; this gave
birth to a dedicated specification document for EL, although EL was always depend-
ent on the same JSR as JSP. Version 3.0 is the first to be developed in a separate
JSR: JSR 341. This new specification comes with many changes; the most important
are: an API for standalone environments, lambda expressions, collection object sup-
port, string concatenation operator, assignment operator, semi-colon operator, and
static fields and methods.
API for standalone environments
Since EL 3.0, it is now possible to handle EL in a standalone environment. For this
purpose, it provides the ELProcessor class, which allows direct evaluation of EL
expressions and makes easier the definition of functions, variables, and local repos-
itory beans. The following code demonstrates how the ELProcessor class can be
used in standalone environment. The present case is the content of a Servlet, but
you can do the same in a Java SE application.
ELProcessor el = new ELProcessor();
//Simple EL evaluation
out.println("<h1>'Welcome to the site!' : "
+ "" + el.eval("'Welcome to the
site!'") + "</h1>");
//Definition of local repository bean
el.defineBean("student", new StudentBean());
//Direct evaluation of EL expression
out.println("<h1>" + el.eval("'The id of :
'+=student.lastName+=' "
+ "is : '+=student.identity") +
//Function definition
el.defineFunction("doub", "hex",
//Access to a function defined
out.println("<h1> The hexadecimal of 29 is : "
+ el.eval("doub:hex(29)") +
Search WWH ::

Custom Search