Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

override the service method in servlet

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a query while going through a tutorial on servlets

If i override the service method , do i need to explicitly call doGet() or doPost()?


could anybody please clarify the above one.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To what purpose would you want to override service()?


 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reason , just wanted to know.
 
Ulf Dittmer
Rancher
Posts: 42968
73
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point Ulf , but why do we need extra control on Http ?

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "extra control". The HTTP extension mechanism is an IETF RFC; WebDAV uses it, and any day there could be other new extensions. Those can only be accommodated by overriding the service method, since the existing implementation couldn't possibly know about them.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean to say that i can override the service() and use HttpServlet class for other protocols other than HTTP.

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. HTTPServlet is for HTTP only - hence its name. HTTP extensions are still based on HTTP, as the name implies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic