Common Java Cookbook

Edition: 0.19

Download PDF or Read on Scribd

Download Examples (ZIP)

9.1. Obtaining Commons JEXL

9.1.1. Problem

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

9.1.2. Solution

To use Commons JEXL in a Maven 2 project, add the following dependency to your project's pom.xml:

Example 9.1. Adding a Dependency on Commons JEXL

<dependency>
  <groupId>commons-jexl</groupId>
  <artifactId>commons-jexl</artifactId>
  <version>1.1</version>
</dependency>

If you are not sure what this means, I'd suggest reading Maven: The Definitive Guide. When you depend on a library in Maven 2, all you need to do is add the dependency groupId, artifactId, and version to your project's dependencies. Once you do this, Maven 2 will download the dependency and make it available on your project's classpath.

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

9.1.4. See Also

To learn more about Commons JEXL, visit the Commons JEXL web site (http://commons.apache.org/jexl/).


Creative Commons License
Common Java Cookbook by Tim O'Brien is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Permissions beyond the scope of this license may be available at http://www.discursive.com/books/cjcook/reference/jakartackbk-PREFACE-1.html. Copyright 2009. Common Java Cookbook Chunked HTML Output. Some Rights Reserved.