Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GenericServlet is abstract?

 
ritesh srivastav
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why GenricServlet decleared abstract?
 
Greg Charles
Sheriff
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a better question you should answer: why should it not be abstract?
 
devasis majhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic