• Post Reply Bookmark Topic Watch Topic
  • New Topic

why most classes and interface in servlet package abstract ?  RSS feed

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please can any one tell me why most classes and interface in servlet package abstract
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is obvious that interfaces must be abstract.

Apart from that, only GenericServlet and HttpServlet classes are abstract (if I am not wrong), so they must be subclassed to create an (HTTP)servlet.

For example, to write a generic servlet, you need only override the abstract service method, because the rest of the methods are already implemented in the GenericServlet class.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces are "rules" so they must be present in specifications implemented by third parties as is the case with servlets and JSP.

Abstract classes let you create your own classes "extending" the abstract functionality. Moreover, they ease the developer by providing dummy method implementations.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!