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.

${employee.lName}

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

Resolver

Example Expression

Description

ArrayELResolver

${myArray[1]}

Returns the value at index 1 in the array called myArray

BeanELResolver

${employee.lName}

Returns the value of the lName property of the employee bean

ListELResolver

${myList[5]}

Returns the value at index 5 of myList list

MapELResolver

${myMap.someKey}

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

ResourceBundleELResolver

${myRB.myKey}

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.