Can you please tell me which method will invoke in the below senario?
what happens if i submit a form without mentioning the method type(get or post) and in called servlet if i have only doPost() method; will doPost() method execute?
If you don't specify a method type, by default it is a GET request, and if you have only doPost(), it doesn't get called, an HTTP status 405 is returned..
P:S: Why can't you try this yourself, instead of waiting for someone to give an answer for you?
Janarthanan Rajendran wrote:its always better to create a service method and call that inside doGet and doPost if your are planning to use both
No it is not. GET and POST should do different things. It's very short-sighted and a violation of the HTTP contract to just have them to the same thing.
Then can you please tell me which method will invoke if i have only doPost method in servlet and did not mention any method type in the form submission?
Bear Bibeault wrote:
Janarthanan Rajendran wrote:its always better to create a service method and call that inside doGet and doPost if your are planning to use both
No it is not. GET and POST should do different things. It's very short-sighted and a violation of the HTTP contract to just have them to the same thing.