wood burning stoves 2.0*
The moose likes JSP and the fly likes Confused about inheritance of HttpJspPage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Confused about inheritance of HttpJspPage" Watch "Confused about inheritance of HttpJspPage" New topic

Confused about inheritance of HttpJspPage

John Strong

Joined: Jul 23, 2006
Posts: 13
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

Joined: Jul 08, 2003
Posts: 24183

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.

[Jess in Action][AskingGoodQuestions]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60732

Moved to the JSP forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60732

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
Don't get me started about those stupid light bulbs.
subject: Confused about inheritance of HttpJspPage
Similar Threads
PageContext and JspContext
Request Dispatcher
What is need of JspPage, HttpJspPage interfaces in JSP
maintaining session
Variable session timout