This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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 ]