I am not able to understand why should not we overload service method directly.Why we overload doGet or doPost methods. I know we should implement doGet or doPost methods because service method call doGet or doPost. I want to know what is "advantage of implement doGet or doPost methods then overloading service method." If it is recommanded that we should always implement doGet or doPost then "why service method is implemented in HttpServlet class."
Hmmm ... Http defines many methods ...like GET , POST , PUT ,TRACE ,HEAD etc.....
service method in HttpServlet forwards the request to one these methods based on the method specified in incoming request.
So in case if you want to your servlet to support get and post but not other methods , then you can only implement doGet and doPost and leave out the other methods . A client trying to do a put request on your servlet gets a status code of 400 meaning operation not supported ...
Joined: Mar 13, 2006
There might be scenarios like you want to respond the GET request in a specific way and the POST request in a way.GET requests are generally meant for just fetching the data and giving it back.And POST request is for updating some thing in the backend.That's why it is called idempotenet. But if you had overriden the serice method instead,you will have only one way of responding.
Hope this helps
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com