aspose file tools*
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
Author

GenericServlet is abstract?

ritesh srivastav
Greenhorn

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

Joined: Oct 01, 2001
Posts: 2850
    
  11

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
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
devasis majhi
Greenhorn

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
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
See https://www.coderanch.com/how-to/java/ServletsFaq#overriding-service for why overriding the service method is generally not what you should do, and https://www.coderanch.com/how-to/java/ServletsFaq#otherProtocols for why GenericServlet and HttpServlet exist as separate classes to begin with.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GenericServlet is abstract?