File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why declare HttpServlet class abstract? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why declare HttpServlet class abstract?" Watch "Why declare HttpServlet class abstract?" New topic
Author

Why declare HttpServlet class abstract?

Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
What is the reason for declaring HttpServlet class abstract? There doesn't seems to be any abstract methods.
Thanks.
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3210
    
    5
Hi.
Because this class is not supposed to be created by user, only Servlet Container can create instances of servlet (it does not make much sense to have servlet object outside servlet container).
And every vendor has it's proprietary implementation of concrete servlet class, which is created inside servlet container.
Cheers !


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
supose you have three classes:
Car, FordFocus,FordF250
suppose you have three guys: A,B, C, each one can have a car:
A.setCar(new FordFocus());
b.setCar(new FordF250());
c.setCar(new Car());//this has no usefull meaning
The point is, Car is so abstract that we can't create cars of this class... The same aplies to HttpServlet, Servlet, GenericServlet... If we could create HttpServlets by just calling one constructor they wouldn't be usefull. Each Servlet MUST be implemented.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why declare HttpServlet class abstract?