Unified Expression Language for JSP

Expression language (EL) became part of Jsp with verion 2.0. It is mainly for web-side development by providing easy access mechanism to Java beans. In recent version of JEE, it has been changed to Unified Expression Language. In Jsp 2.1, the expression language is unified with expression language for Java Server Faces (JSF) technology (version 1.0). The reason is simple, both the technologies are used to write presentation tier or web tier, hence the language used to write this should be unified. Let us see what are the additional features of JSF, that are combined with EL.

EL allowed access to the Java beans using ${expression}. In addition to this, following JSF expression language features are integrated now.

Important features of the Unified Expression language are discussed below.

Evaluation:

Two options are possible here, immediate evaluation where the expression is evaluated immediately and the value is printed in jsp, deferred evaluation where the evaluation is done by the technology using expression language at run time/whenever required. Immediate evaluation is implemented using ${….} while deferred evaluation is implemented using #{….}.

Value Expressions:

Return value after evaluating expressions. Two categories are possible for value expressions, Rvalue- read data and Lvalue – read and write data. Expressions with ${user.firstName} are always Rvalue while #{user.firstName} can be Rvalue or Lvalue depending on underlying technology evaluation.

Method Expressions:

These are similar to the value expressions, except that there would be actual method call on the bean instead of a get or set method call. Hence ${user.validateUser} will result in validateUser() method call on the user object.

Implicit Objects:

These implicit objects are available in unified expression language – pageContext, servletContext, session, request, response, param, paramValues, header, headerValues, cookie, initParam.

Scope Objects:

Objects can be retrieved using these scope objects. Different scope objects available are pageScope, requestScope, sessionScope, applicationScope. Syntax is ${sessionScope.userProfile}.

 <<Previous   Home   Next>>

  • Share/Bookmark
JEE, Jsp, Tech Notes

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

One Response to “Unified Expression Language for JSP”

Leave Comment

(required)

(required)