The Java EE 5 Tutorial

Resolving Expressions

The unified EL introduces a new, pluggable API for resolving expressions. The main pieces of this API are:

Most application developers will not need to use these classes directly unless they plan to write their own custom EL resolvers. Those writing JavaServer Faces custom components will definitely need to use ValueExpression and MethodExpression. This section details how expressions are resolved for the benefit of these developers. It does not explain how to create a custom resolver. For more information on creating custom resolvers, see the article The Unified Expression Language, Ryan Lubke et al., located at You can also refer to Request Processing, which explains how the Duke’s Bank application uses a custom resolver.

Process of Expression Evaluation

When a value expression that is included in a page is parsed during an initial request for the page, a ValueExpression object is created to represent the expression. Then, the ValueExpression object’s getValue method is invoked. This method will in turn invoke the getValue method of the appropriate resolver. A similar process occurs during a postback when setValue is called if the expression is an lvalue expression.

In the case of a method expression, a BeanELResolver is used to find the object that implements the method to be invoked or queried. Similarly to the process for evaluating value expressions, when a method expression is encountered, a MethodExpression object is created. Subsequently, either the invoke or getMethodInfo method of the MethodExpression object is called. This method in turn invokes the BeanELResolver object’s getValue method. The getMethodInfo is mostly for use by tools.

After a resolver completes resolution of an expression, it sets the propertyResolved flag of the ELContext to true so that no more resolvers are consulted.

EL Resolvers

At the center of the EL machinery is the extensible ELResolver class. A class that implements ELResolver defines how to resolve expressions referring to a particular type of object or property. In terms of the following expression, a BeanELResolver instance is called the first time to find the base object, employee, which is a JavaBeans component. Once the resolver finds the object, it is called again to resolve the property, lName of the employee object.


The unified EL includes a set of standard resolver implementations. Table 5–4 lists these standard resolvers and includes example expressions that they can resolve.

Table 5–4 Standard EL Resolvers


Example Expression 




Returns the value at index 1 in the array called myArray



Returns the value of the lName property of the employee bean



Returns the value at index 5 of myList list



Returns the value stored at the key, someKey, in the Map, myMap



Returns the message at myKey in the resource bundle called myRB

Depending on the technology using the unified EL, other resolvers might be available. In addition, application developers can add their own implementations of ELResolver to support resolution of expressions not already supported by the unified EL by registering them with an application.

All of the standard and custom resolvers available to a particular application are collected in a chain in a particular order. This chain of resolvers is represented by a CompositeELResolver instance. When an expression is encountered, the CompositeELResolver instance iterates over the list of resolvers and consults each resolver until it finds one that can handle the expression.

If an application is using JSP technology, the chain of resolvers includes the ImplicitObjectELResolver and the ScopedAttributeELResolver. These are described in the following section.

See section JSP 2.9 of the JavaServer Pages 2.1 specification to find out the order in which resolvers are chained together in a CompositeELResolver instance.

To learn how to create a custom EL resolver, see The Unified Expression Language .