Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why HHTP servlet is defined as abstract?

 
ravi lingala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please clarify this.

1.Why HHTP servlet is defined as abstract servlet ?Even though it doesnt have any abstract methods.All the methods in it are all protected only.
2.If we dont override any do() method, then why our own servlet will become abstract?
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravi lingala wrote:Hi All,
2.If we dont override any do() method, then why our own servlet will become abstract?


what does this mean ???

HttpServlet provides dummy implementation for all doXxx methods . there is no need to override them for compilation.
well we should override one of them to provide functionalities otherwise an error message will be generated by the container if the method is requested(not exception).
avi sinha
 
ravi lingala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks avi Sinha for giving clarification.
As per your clarification, if I don't override any doxx() methods in my servlet then my servlet will not become abstract.
we overrdie doXXmethods() only to provide functionality.
But I still did not understand why HTTP servlet is defined as abstract(if there are no abstract methods).
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I don't override any doxx() methods in my servlet then my servlet will not become abstract.

No, it's the other way around - if you override one of the methods, then the class is no longer abstract.

But I still did not understand why HTTP servlet is defined as abstract(if there are no abstract methods).

To indicate that one of the methods must be overridden to obtain a meaningful servlet. If none of the doXYZ methods are overridden, then a 405 is returned for most HTTP methods - not useful at all.
 
ravi lingala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf Dittmer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic