This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Confused about inheritance of HttpJspPage" Watch "Confused about inheritance of HttpJspPage" New topic
Author

Confused about inheritance of HttpJspPage

John Strong
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Moved to the JSP forum.


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

Joined: Jan 10, 2002
Posts: 60794
    
  65

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confused about inheritance of HttpJspPage
 
Similar Threads
Variable session timout
PageContext and JspContext
Request Dispatcher
What is need of JspPage, HttpJspPage interfaces in JSP
maintaining session