Unified Expression Language for JSP - JEE
Home » JEE, Jsp, Tech Notes

Unified Expression Language for JSP

16 April 2009 One Comment

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.

  • Deferred evaluation of expressions
  • Ability to get and set data
  • Ability to invoke methods

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

 

More Related Posts in JEE, Jsp, Tech Notes

One Comment »

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.