You need to use Commons JEXL to evaluate a simple expression that contains references to variables and object properties.
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.
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.
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.
To learn more about Commons JEXL, visit the Commons JEXL web site (http://commons.apache.org/jexl/).