9.1. Obtaining Commons JEXL

Problem

You need to use Jakarta Commons JEXL to evaluate a simple expression that contains references to variables and object properties.

Solution

You must download the latest version of Commons JEXL, and place the Commons JEXL JAR in your project’s classpath. Follow the steps outlined in Recipe 1.1, downloading Commons JEXL 1.0 instead of Commons Lang.

Commons JEXL depends on Commons Logging 1.0.3, which can be downloaded from the same location as Commons JEXL.

Discussion

Commons JEXL is an expression language interpreter influenced by the expression language features of JSP 2.0; JEXL is an extended version of JSP 2.0 EL that does not depend on the Servlet API. This means that it can be integrated into any application that needs to use an expression language.

Tip

JEXL is similar to EL with one major difference. The JSP 2.0 EL implementation project in Jakarta Commons, Commons EL, is covered by a Java Specification Request (JSR), which was developed under the Java Community Process (JCP). Because of this, EL is bound to implement the JSP specification—no more and no less. On the other hand, JEXL is free to extend and improve upon the standard.

If you have a Maven project, which needs to use Commons JEXL, add a dependency on Commons JEXL 1.0 with the following section in project.xml:

<dependencies>
  <dependency>
    <id>commons-jexl</id>
    <version>1.0</version>
  </dependency>

  ....other dependencies...
</dependencies>

See Also

For more information about downloading Commons ...

Get Jakarta Commons Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.