aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Q: Data type for JSP implicit objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Q: Data type for JSP implicit objects" Watch "Q: Data type for JSP implicit objects" New topic
Author

Q: Data type for JSP implicit objects

Anand Wadhwani
Ranch Hand

Joined: Mar 21, 2005
Posts: 151
Q:

For JSP scopes of request and page, what type of object is used to store the attributes?

Select 1 correct option.
a HttpServletRequest and ServletContext respectively.
b ServletRequest and ServletConfig respectively.
c ServletRequest and PageContext respectively.
d HttpServletRequest and PageContext respectively.
e ServletConfig for both.

The answe to this question is c, but in my opinion it should be d.

The exaplination which is given for answer-c is as follows:
-----------------------------------------------------
Although HttpServletRequest is a subclass of ServletRequest, the feature of storing attributes is common to all servlets and jsps and not just HttpServlets and JSPs for HTTP.
-----------------------------------------------------

But as per JSP 2.0 specification data type for request and response is HttpServletRequest and HttpServletResponse respectively.

Please advise.


SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
Kris Reid
Ranch Hand

Joined: Jan 05, 2005
Posts: 247
I thought it would be HttpServletRequest

However JSP are also designed to use other prtocols then HTTP.
So that is probable why it is the more generic ServletRequest
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
Hello,
ServletRequest has setAttribute() method.

the feature of storing attributes is common to all servlets and jsps and not just HttpServlets and JSPs for HTTP


This explanation is correct.

Although HttpServletRequest extends ServletRequest whenever the container implements the HttpServletRequest interface {which means makes an HttpServletRequest class} it won't give the implementation of setAttribute in it. Rather the implementation of the setAttribute will be in the ServletRequest class that the container makes.

Also it is very unlikely that some one will code a Servlet that is not HTTP but the feature is still there for others who do want to code a non Http Servlet.

Hope that helps.


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q: Data type for JSP implicit objects