Jump to content

Jakarta Expression Language

From Alfawiki
Jakarta Expression Language
Company typeProgramming language specification
IndustrySoftware development
PredecessorExpression Language, Unified Expression Language
ProductsExpression language for Jakarta EE web applications

The Jakarta Expression Language (EL; previously known as Expression Language and Unified Expression Language) is a specialized programming language designed mainly for use within Jakarta EE web applications to embed and evaluate expressions in web content. It was initially introduced in the JSP 2.1 specification (JSR-245) and subsequently became standardized independently under JSR-341 as part of Java EE 7.

Origins within JSTL

The EL originated inside the JavaServer Pages Standard Tag Library (JSTL) as SPEL (Simplest Possible Expression Language), later simply called Expression Language (EL). Its purpose was to facilitate access to JavaBean components through JSP, streamlining the interaction with Java code. Starting from JSP 2.0, EL was embedded within JSP tags to separate Java logic from markup and simplify access to Java components.

JSP 2.0 Development

With its advancement, EL was integrated into JSP 2.0, introducing enhanced capabilities that made scripting more approachable for web developers with limited Java expertise. Before EL, JSP development depended heavily on tags like scriptlets containing explicit Java code. EL enabled developers to call Java methods without requiring deep knowledge of Java programming.

Its syntax shared similarities with JavaScript expressions:

  • Implicit type conversions without explicit casting
  • No distinction between double and single quotes
  • The notation object.property is equivalent to object['property']

EL abstracts property access so that object.property may internally correspond to methods such as object.get("property") or object.getProperty(), depending on the object's implementation.

Enhancements in EL 2.1

The advent of JavaServer Faces introduced demands beyond what JSP 2.0 EL could provide—such as the need for deferred expression evaluation and method invocation on server-side objects. EL 2.1 addressed these by adding:

  • Deferred expressions evaluated at a later point
  • Expressions capable of both retrieving and modifying values
  • Method expressions allowing invocation of server-side functions

To eliminate discrepancies between JSP EL and JSF EL, these were merged into a unified expression language starting with JSP 2.1, simplifying development across Jakarta EE frameworks.

Introduction of EL 3.0

Developed independently under JSR-341, separate from JSP and JSF specifications, EL version 3.0 introduced major improvements including support for Java 8-style streams and lambda expressions within the expression language.

Transition in EL 4.0

Released on 2020-10-07, version 4.0 migrated the API package from javax.el to jakarta.el in alignment with the transition from Java EE to Jakarta EE as part of Jakarta EE 9.

Updates in EL 5.0

Launched on 2022-09-05, version 5.0 eliminated deprecated methods, clarified ambiguous aspects of the specification, and implemented usability enhancements. This release is included within Jakarta EE 10.

Features

The consolidated EL merges features from both JSP and JSF expression languages, providing:

  • Deferred expression evaluation capabilities
  • Support for expressions that can both set values and invoke methods
  • A modular API enabling customizable expression resolution

Examples

An illustration of Unified EL usage inside a JSTL "c:out" element:

<c:out value="${myBean.myField}" />

Invoking a method with an argument:

${myBean.addNewOrder('orderName')}

Implementations

  • Java Expression Language (JEXL) offers dynamic scripting capabilities for Java applications and frameworks. Most recent version: 3.2.1 (June 2021).
  • JUEL is a reliable open-source implementation of Unified EL aligned with JSP 2.1 (JSR-245), distributed under the Apache License 2.0, and applicable beyond JSP environments. Latest update: Version 2.2.7 (February 2014).
  • Apache Commons EL serves as the EL interpreter for JSP 2.0 from Apache; its final release was Version 1.0 (June 2003), though source code and binaries are no longer provided.

See also

  • OGNL – An open-source EL employed by WebWork and Struts2.
  • MVEL – Open-source EL utilized across numerous Java projects.
  • SpEL – Spring Expression Language, integrated within the Spring Framework, primarily designed for Spring but usable independently.
  • Ant-Flaka – An EL tool that streamlines Ant build scripts.
  • CEL – Google's open-source expression language.

External links