Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic Question about Service Method

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In above code if i will replace doPost method with service method i will get same result.
Then why specialized methods(doGet,doPost) are required.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works because the service method looks at the request, and then dispatches it to doGet, doPost, etc. as appropriate. It's quite possible that different things should happen depending on whether it's GET, POST, HEAD, or any of the other HTTP methods.
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
How come it will work if you replace your doPost method with service method if you are extending HttpServlet Class??
If you extend GenericServlet, it will work..
please correct me if i am wrong!!
krishna.
 
navat venu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come it will work if you replace your doPost method with service method if you are extending HttpServlet Class??
If you extend GenericServlet, it will work..


HttpServlet class extends GenericServlet class.
HttpServlet class contains overridden service method i.e.,
service(HttpServletRequest,HttpServletResponse)

hope this clarifies!!
 
navat venu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpServlet class contains overridden service method i.e.,
service(HttpServletRequest,HttpServletResponse)


HttpServlet class contains overloaded service method i.e.,
service(HttpServletRequest,HttpServletResponse).
HttpServlet implements the service method to reflect the HTTPness
of the servlet.

whereas Generic Servlet has service method i.e.,
service(ServletRequest,ServletResponse) .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic