*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Correct EL expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Correct EL expression" Watch "Correct EL expression" New topic
Author

Correct EL expression

Robert O'Leary
Ranch Hand

Joined: Mar 24, 2009
Posts: 41
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?


SCJP6
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 165

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

Joined: Aug 03, 2008
Posts: 9302
    
  17

Bindu Lakhanpal wrote:There is no implicit request object in EL.There is a requestScope object


I forgot that ...
Siphiwe Madi
Ranch Hand

Joined: Aug 16, 2007
Posts: 70
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.


Regards, Siphiwe Madi
[SCJP, SCWCD, __] Next ... scjwsd
Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 327
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

Joined: Apr 21, 2008
Posts: 432
Hi Harshana. See getRequestURI here.
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 165

URI is uniform resource Identifier.
Also check SRV 4.4.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Correct EL expression