File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes GenericServlet is abstract? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "GenericServlet is abstract?" Watch "GenericServlet is abstract?" New topic

GenericServlet is abstract?

ritesh srivastav

Joined: Nov 30, 2012
Posts: 8
why GenricServlet decleared abstract?
Greg Charles

Joined: Oct 01, 2001
Posts: 2968

Well, what does abstract mean? GenericServlet and its child HttpServlet are meant to provide a framework for the concrete servlets that you write to do something interesting. They're not meant to be instantiated themselves, and if you could instantiate one of them, it wouldn't do anything for you.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

Here's a better question you should answer: why should it not be abstract?

[Asking smart questions] [About Bear] [Books by Bear]
devasis majhi

Joined: Dec 29, 2012
Posts: 9
I think this the way Servlet API has been designed to force the developer to implement the service() of GenricServlet to process client request or response. If it would have not been an abstract class I don't see any harm in it. Those who want to customize their service method they could have overridden it and do what they want to do.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
See for why overriding the service method is generally not what you should do, and for why GenericServlet and HttpServlet exist as separate classes to begin with.
I agree. Here's the link:
subject: GenericServlet is abstract?
It's not a secret anymore!