So I have this simple code in a jsp file:
${requestScope.getClass()}
which returns me:
class javax.servlet.jsp.el.ImplicitObjectELResolver$ScopeManager$9
which makes me think this object is of type ImplicitObjectELResolver. (I may be wrong even here..)
Well, when I look at the documentation here for this nice class: javax.servlet.jsp.el.ImplicitObjectELResolver , I see:
Defines variable resolution behavior for the EL implicit objects defined in the JSP specification.
The following variables are resolved by this ELResolver, as per the JSP specification:
pageContext - the PageContext object. pageScope - a Map that maps page-scoped attribute names to their values.
requestScope - a Map that maps request-scoped attribute names to their values.
Now I am confused because here I am thinking I already have the an object of type Map. But the object I have is supposed to have a variable called requestScope which is a Map..
So what actually happens when I call
${requestScope.firstName}
for example?
Am I calling getKey("firstName") on a Map object, or is something else going on?
The JSP servlet, as part of the EL resolution, will use the ImplicitObjectELResolver
to resolve the name requestScope
. That resolution consists in invoking getRequestScopeMap()
which returns an anonymous inner class of type EnumeratedMap<String, Object>
which has access to all attributes in the request scope.
Once that EnumeratedMap
is return, the EL resolution will continue by trying to invoke the Map
's get(..)
method with the given name in the EL expression. For example, the name is firstName
in
${requestScope.firstName}
The implementation may have changed from version to version.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments