File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes calling sub class' method from super class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling sub class Watch "calling sub class New topic
Author

calling sub class' method from super class

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Hi,

This line is with reference to page 294 of HFS&J.

"Builds the service() method. This service method's actual name is _jspService(). It's called by the servlet superclass' overridden service() method....."

So in case of tomcat, the super class of this servlet (which was JSP before) is HttpJspBase. This HttpJspBase is also servlet (extends HttpServlet) and has overriding service() method. Now this overriding service() method calls our _jspService() method...

I am confused, how can we call sub class' method from super class without even knowing the name of sub class???

Hope my question is clear.
Thanks.

[ May 16, 2006: Message edited by: rathi ji ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Because HttpJspBase defines the _jspService method as abstract.

for example:


The container is going to instanciate your jsp with something like:
HttpJspBase servlet = new MyJspFile();

I hope this is clear enough.


[My Blog]
All roads lead to JavaRanch
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It says:
from the superclass' overridden service() method


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Thanks Ben and Satou.
I got the point Ben.

[ May 16, 2006: Message edited by: rathi ji ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling sub class' method from super class