Expression Language | Home: http://pwall.net |
Email: Needs JavaScript |
ON THIS PAGE:
OTHER PAGES:
|
When the
JSP
Standard Tag Library
(JSTL) was announced, it included an Expression Language for the
definition of expressions in conditional tags, in iteration and for other
uses.
It struck me that it would be useful to have a generalized expression
evaluation system, for use in a variety of circumstances going beyond its
initial implementation in JSP.
This seemed like an interesting programming challenge, and I quickly
produced an initial version of the Expression Language system, written in
Java.
That was back in 2002, and the project gone through a series of changes
since then.
Of course, Sun has more recently made the Expression Language available as
a separate subsystem — the
javax.el package —
and this takes away some of the need for a separate package such as mine.
But some people may still find value in my version.
I find it easier to use than the Sun package — but then, I wrote
it, so I'm thoroughly familiar with it.
It may perform better (I haven't run any tests, so this is speculation).
And there's always the advantage (to some users) of having a
fully-documented open source version that may be modified at will.
The original version of this system implemented the Expression Language
specification in “JavaServer Pages™ Standard Tag
Library” published by Sun Microsystems, Inc.
It was written in Java, using Java SE 1.4.2.
Subsequently, at the request of users of the system, I added further
functionality to extend its usefulness, but in order to maintain strict
compatibility with the basic specification, I made these additional
facilities available only to those who explicitly enable them (see the
Javadoc for the
Expression and Expression.Parser
classes for details).
More recently a version of the Expression Language system in JavaScript
has been produced.
This may seem superfluous since JavaScript allows any expression to be
evaluated at run-time, but the use of a separate expression handler allows
more control over the objects that may be accessed, and prevents the code
injection security exploits that are a significant danger with arbitrary
JavaScript expression evaluation.
All versions of the Expression Language translator/evaluator follow a
two-pass approach, first compiling the text representation of the
expression into a tree structure, and then executing that compiled form.
One common use of the system in its early days was to provide Expression
Language processing on JSP custom tags written to coexist with JSTL tags.
Prior to JSP 2.0, the JSP system would not recognize EL constructs in
custom tag attributes, so this was the responsibility of the tag writer.
The EL, with the class
JspResolver , provides a simple way
for the custom tag writer to provide full expression evaluation and
substitution in tag attributes.
(This is of less significance since application servers compatible with
JSP 2.0 are now widely available, but some corporate users are constrained
for various reasons to using earlier versions so this aspect of the
Expression Language may still be of some benefit.)
For those people who wish to use the library but not modify it, a JAR file
containing the classes is available for download.
A ZIP file of the Javadoc for the library is also available.
And for those who wish to modify the source or just to peruse it, a ZIP
file of the entire project (source, Ant build file etc.) is available.
The JavaScript version is available as a separate download.
Do not deep-link to the download files — the URLs include a
numeric IP address which may change from time to time.
To use this library in a JSP context, the JAR file
servlet.jar must be obtained from Sun, or from a Java EE
application server vendor.
Another good source is the
Tomcat Project.
To build the project, a copy of this JAR file must be placed in the
“lib ” directory of the project.
Javadoc for the project may be perused online:
Please use this only for occasional reference; for repeated use please
download the ZIP of the Javadoc (see above).
Do not deep-link to the online Javadoc — the URL includes a
numeric IP address which may change from time to time.
This software is copyright © 2002 – 2008 Peter Wall.
It is licensed under the
GNU Lesser General Public
License.
|