Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Q: Data type for JSP implicit objects

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Evacuate the building! Here, take this tiny ad with you:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic