How does requestScope object of Expression Language work in a JSP file?

Koray Tugay

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?

Sotirios Delimanolis

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Hibernate expression language does not work

From Dev

Hibernate expression language does not work

From Dev

Simple JSP expression language code won't work

From Dev

JSP 2 Expression Language

From Dev

JSP Expression language syntax

From Dev

How to use requestScope to pass value from jsp to portlet

From Dev

how to make expression language jump across multiple jsp pages?

From Dev

How to call java constant variables from jsp expression language in Spring?

From Dev

How to share values between jsp Expression Language and javascript?

From Dev

JSP Expression Language get parameter

From Dev

XPath expression in xsl file does not work in IE

From Dev

how does jsp:useBean scope attribute work?

From Dev

HYBRIS - How components and slots work in JSP file?

From Dev

HYBRIS - How components and slots work in JSP file?

From Dev

JSP EL not finding requestScope variable?

From Dev

from an expression to a language object

From Dev

from an expression to a language object

From Java

How does the language in which Vim operates work?

From Dev

How does language support work in Lubuntu?

From Dev

How does language support work in Lubuntu?

From Dev

How does Arduino Wiring Language work?

From Dev

How does an event object work?

From Dev

How does an equal to expression work in a printf placeholder?

From Dev

How does the expression `ap zip tail` work

From Dev

How does the expression `ap zip tail` work

From Dev

How does this call/cc expression work?

From Dev

How/why does this globbing expression work?

From Dev

how does the expression b=${b:-"/data"} work

From Dev

How does `cat <> file` work?