Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Correct EL expression

 
Robert O'Leary
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is from Javabeat...

Which EL expression evaluates to the request URI?
A. ${requestURI}
B. ${request.URI}
C. ${request.getURI}
D. ${request.requestURI}
E. ${requestScope.requestURI}
F. ${pageContext.request.requestURI}
G. ${requestScope.request.request.URI}
Answer: F

Is D not correct as well as F?
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the request object in EL is a Map of request attributes. So you can't access normal request values from it. The pageContext.request represents the normal HttpServletRequest object so you can access the request URI from it...
 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no implicit request object in EL.There is a requestScope object which is a map of the request scope attributes.It is not the request object itself.
And requestURI(a String containing the part of the URL from the protocol name up to the query string) is a property of request ( HttpServletRequest).
For getting request properties, we need pageContext implicit object of EL. pageContext is used to access the JSP's regular implicit objects such as application, session and request.
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bindu Lakhanpal wrote:There is no implicit request object in EL.There is a requestScope object


I forgot that ...
 
Siphiwe Madi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The easiest way for me not to forget is remembering that:
- pageContext is the only actual reference to an actual object (PageContext) which you can then use to access other normal implicit objects (request, application, session) e.t.c

all the others EL implicit objects are Map to, for example, access attributes, initialization parameters, e.t.c.
 
Harshana Dias
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is actually requestURI?

Only F is correct if there is something as requestURI right?

but its not there in HttpServletRequest or ServletRequest know?

where is it please?
 
Chinmaya Chowdary
Ranch Hand
Posts: 432
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harshana. See getRequestURI here.
 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URI is uniform resource Identifier.
Also check SRV 4.4.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic