• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confused about inheritance of HttpJspPage

 
John Strong
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Supposedly, when the Container receives a JSP, it generates an HttpServlet object, but when I look at the example code on p. 295 of HFSJ, the generated class extends HttpJspPage, not HttpServlet.

Now, this confuses me, for several reasons:
(1.) HttpJspPage is not an extension of HttpServlet, it is an interface, according to
http://java.sun.com/j2ee/sdk_1.2.1/techdocs/api/javax/servlet/jsp/HttpJspPage.html. Why would the generated class be *extending* (rather than implementing) an interface?

(2.) If the generated servlet really did extend HttpServlet, it would not inherit the HttpJspPage interface, because HttpServlet inherits the implementation of the Servlet interface from GenericServlet, but it does not inherit HttpJspPage.

Who inherits what here? Who gets the house, who gets the car, who gets the kids???

Thanks, - John Strong (pluviosilla@gmail.com)
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have HFSJ, so I can't explain exactly what the book page is saying, but the requirement is just that the generated class implement HttpJspPage. The container is not required to do so by extending HttpServlet, although it certainly could if it wanted to.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the generated class extends HttpJspPage,


The book does not say that. It extends HttpJspBase which is an internal Tomcat class.

org.apache.jasper.runtime.HttpJspBase extends HttpServlet and implements javax.servlet.jsp.HttpJspPage.

See http://tomcat.apache.org/tomcat-4.1-doc/jasper/docs/api/org/apache/jasper/runtime/HttpJspBase.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic