World Library  
Flag as Inappropriate
Email this Article

Expression Language

Article Id: WHEBN0009346488
Reproduction Date:

Title: Expression Language  
Author: World Heritage Encyclopedia
Language: English
Subject: Apache Tomcat, El, OGNL, Unified Expression Language, OpenSocial, MVEL, ZK (framework)
Collection:
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Expression Language

The Java Unified Expression Language is a special purpose programming language mostly used in Java web applications for embedding expressions into web pages. The Java specification writers and expert groups of the Java web-tier technologies have worked on a unified expression language which was first included in the JSP 2.1 specification (JSR-245), and later specified by itself in jsr-341, part of Java EE 7.

History

The expression language started out as part of the JavaServer Pages Standard Tag Library (JSTL) and was originally called SPEL (Simplest Possible Expression Language), then just Expression Language (EL). It was a scripting language which allowed access to Java components (JavaBeans) through JSP. Since JSP 2.0, it has been used inside JSP tags to separate Java code from JSP, and to allow easier access to Java components (than in Java code).

Over the years, the expression language has evolved to include more advanced functionality and it was included in the JSP 2.0 specification. Scripting was made easier for web-content designers who have little or practically no knowledge of the core Java Language. This scripting language made JSP a scripting language in the true sense. Before EL, JSP consisted of some special tags like scriptlets, expressions etc. within which Java code was written explicitly. With EL the web-content designer needs only to know how to make proper calls to core Java methods.

EL was, both syntactically and semantically, similar to JavaScript expressions:

  • there is no typecasting
  • type conversions are usually done implicitly
  • double and single quotes are equivalent
  • object.property has the same meaning as object['property']

EL also liberated the programmer from having to know the particularities of how the values are actually accessed: object.property can mean (depending on what the object is) either object.get("property") or object.getProperty("property") or object.getProperty() etc.

During the development of JSP 2.0, the JavaServer Faces technology was released which also needed an expression language, but the expression language defined in the JSP 2.0 specification didn't satisfy all the needs for development with JSF technology. The most obvious limitation is that its expressions are evaluated immediately. And also, the JSF components need a way to invoke methods on server-side objects. A more powerful language was created with the following new features:

  • Deferred expressions, which are not immediately evaluated
  • Expressions that can set as well as get data
  • Method expressions, which can invoke methods

The new expression language worked well for the purposes of JSF. But developers had problems when integrating the JSP EL with the JSF EL because of conflicts. Because of these incompatibilities, the unified expression language initiative was started to unify these expression languages. As of JSP 2.1, the expression languages of JSP 2.0 and JSF 1.1 have been merged into a single unified expression language (EL 2.1).

Version 3.0 of the expression language (the unified was no longer deemed necessary) was developed in a JSR independent of the JSP and JSF specifications in JSR-341 . Some new features were added, most notably EL equivalents of Java 8's streams and lambda expressions.[1]

Features

The new unified EL is a union of the JSP and JSF expression languages. In addition to the features already available in the JSP EL, the unified EL has the following features:

  • Deferred evaluation
  • Support for expressions that can set values and expressions that can invoke methods
  • A pluggable API for resolving expressions

Examples

This shows a simple example of Unified EL being used within a JSTL "c:out" tag:


An expression that calls a method with a parameter:

${myBean.addNewOrder('orderName')}

Implementations

  • JUEL is an open-source implementation of the Unified Expression Language 2.1. It is considered stable and feature complete and is licensed under the Apache License 2.0. JUEL is also suitable for use in non-JSP applications.
  • Apache Commons EL is the JSP 2.0 EL interpreter from Apache.

See also

  • OGNL – An open source EL used by WebWork (and Struts2).
  • MVEL – An open source EL used in many Java-based projects.
  • Apache Commons JEXL – An open source EL intended to facilitate the implementation of dynamic and scripting features for Java-based projects
  • SpEL – Spring Expression Language, an open source EL that is part of the Spring Framework. It's mainly used in Spring portfolio projects but because it's technology-agnostic it may be used in other projects.

References

  1. ^ https://weblogs.java.net/blog/swchan2/archive/2013/07/01/standard-deviation-illustration-expression-language-30-servlet-environment

External links

  • JSR 245: JavaServer Pages 2.1
  • Unified Expression Language (article at Sun Developer Network (SDN)
  • Expression Language
  • Unified Expression Language for JSP and JSF (article at java.net)
  • JUEL is an implementation of the Unified Expression Language (EL), specified as part of the JSP 2.1 standard (JSR-245).
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.