aspose file tools
The moose likes Servlets and the fly likes why we use doGet() and doPost() in the place of service(ServletRequest req,servletResponse) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "why we use doGet() and doPost() in the place of service(ServletRequest req,servletResponse)" Watch "why we use doGet() and doPost() in the place of service(ServletRequest req,servletResponse)" New topic
Author

why we use doGet() and doPost() in the place of service(ServletRequest req,servletResponse)

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 97
why we use doGet() and doPost() in the place of public void service(ServletRequest req,servletResponse resp).

we can also use service(ServletRequest req,servletResponse resp).
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 3791
    
    1

Why would you want to? It's much easier to use the provided methods.

The service() method is defined in GenericServlet, which was intended to be able to support different protocols. In practice you're always going to be using HTTP. The service() method is implemented in HttpServlet in a way that makes life simpler - it does all the mapping of HTTP requests for you, so all you need to do is implement the ones you want to use.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

we have an entry about it in ServletsFaq
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

Although most people make POST and GET do the same thing, that's a really bad practice. POST and GET should be used for very different things according to the way HTTP was designed.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: why we use doGet() and doPost() in the place of service(ServletRequest req,servletResponse)
 
Similar Threads
servlets
what if doGet is called when it is not implemented?
doGet and doPost
Why the service methods in HttpServlet abstract class are protected?
Default implementation of service method in HttpServletClass