• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Basic Question about Service Method

 
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
 
Rancher
Posts: 43016
76
  • 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.
 
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.
 
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) .
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic