Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in jsp and el implicit objects

 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We have JSP implicit Objects request,session,application,page and EL implicit Objects like requestScope,sessionScope,applicationScope and pageScope i wanted to know the difference between them I have read about these in HFSJ that requestScope will not have actual refrence of the Actual instance of request rather it can access only the attributes of the request and not the properties of request object

can any body please explain me clearly with an example the differences between these implicit objects.

Thanks
 
Ramkumar Rao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raja,

You have the answer for your question. requestScope is not an instance of HttpServletRequest, rather its an implicit Map object provided by EL. So it can be used to get the attributes value from the request scope. We have to use pageContext implicit object to get the request object in EL.

Whereas, the request implicit object given by JSP is an instance of HttpServletRequest and can be used to access all the methods in the ServletRequest interface.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

any more updates on this

Thanks
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
requestScope is a reference to request attributes, not a reference to HttpServletRequest. If you check the API of HttpServletRequest you will find alot of methods that you can't invoke unless you have a reference to an HttpServletRequest object.

this means that you can't say:
requestScope.getInputStream() OR
requestScope.inputStream.
if you need to do so then you would have to use the pageContext, something like pageContext.request.requestURI

you can only access attributes of request scope: requestScope.attribute_name.
Hope that cleared it.
[ June 04, 2008: Message edited by: Musab Al-Rawi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic