File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes HttpServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServlet" Watch "HttpServlet" New topic


Ajit Shanbhag

Joined: Oct 15, 2008
Posts: 7
Can anyone please tell me what is the specific reason for having HttpServlet as an abstract class without any abstract methods?

Ajit Shanbhag
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
Because -in order to be useful- at least one of its methods (generally doGet or doPost) needs to be overridden. Making HttpServlet abstract ensures that it can't be used directly - it needs to be subclassed in order to be instantiated.
Ajit Shanbhag

Joined: Oct 15, 2008
Posts: 7
Consider Paul's rocket mass heater.
subject: HttpServlet
It's not a secret anymore!