aspose file tools*
The moose likes Servlets and the fly likes Why HTTPServlet class is abstract? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why HTTPServlet class is abstract?" Watch "Why HTTPServlet class is abstract?" New topic
Author

Why HTTPServlet class is abstract?

Vaibhav G Garg
Ranch Hand

Joined: Sep 23, 2011
Posts: 140
I have just found that HTTPServlet class doesn't contain any abstract methods but still it is declared as an abstract class. Can anyone please suggest a reason for marking this class as ABSTRACT.
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Because HttpServlet is not designed to solve all web sites specific problems.

Every java programmer will write she/he's own java concrete servlet for her/his purpose, extending it, and taking advantage from the http protocol facilites, already implemented and ready to use, provided by the superclass HttpServlet.

Hope this helps a bit.


Bye,
Nicola
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4464
    
    8

Note that when you extend HttpServlet you need to override one of the doXXX methods (doPost, doGet etc). You don't need to override all of them (and you usually won't). Which means they can't be marked as abstract - if they were, you'd be forced to implement them all. But an unmodified HttpServlet is pretty useless, so it's worth labelling it abstract to emphasis it is not intended to be instantiated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why HTTPServlet class is abstract?