• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question 14, chapter 7

 
Alex Matute
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

Is question 14 of chapter 7 correct? It's about the type of the JSP implicit request and response objects, I would say they are of type HttpServletRequest and HttpServletResponse respectively and not ServletRequest and ServletResponse as the answer states.

I know it's mostly the same and indirectly, they are of their super class type but you know how this picky exam questions are...

--Alex
 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,
I checked the spec, it gave the following info
protocol dependent subtype of:
javax.servlet.ServletRequest
e.g:
javax.servlet.http.HttpServletRequest

But now I am too getting confused, if we consider the parent class, then that means for each usage of request object would require a cast.

Secondly then session should also be javax.servlet.session rather than HttpSession.....

any explanation...
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alex Matute:
I know it's mostly the same and indirectly, they are of their super class type but you know how this picky exam questions are...

Careful calling it superclass - both ServletRequest and HttpServletRequest are interfaces.

But you are right that it's an indirect correct answer, as the types are in fact HttpServletRequest and HttpServletResponse, which are interfaces that extend their respective non-Http counterparts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic