• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused about inheritance of HttpJspPage

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the JSP forum.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic