Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Why HHTP servlet is defined as abstract?

 
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?
 
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).
 
Rancher
Posts: 43016
76
  • 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
 
Where does a nanny get ground to air missles? Protect this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic