File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
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: 100
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: 4387
    
    8

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: 61201
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why we use doGet() and doPost() in the place of service(ServletRequest req,servletResponse)