0

Hi daniweb team,
I am new to Servlet concepts can any one tell why peoples use doGet and doPost method in the Same program.And What is the difference between doGet and doPost method.

Thank you,

With Regards,
Prem.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by prem2
1

doGet method maps to the code executed when your servlet receives a "GET" HTTP request. doPost method maps to the code executed when your servlet receives a "POST" HTTP request. These methods are internally called by the `execute` method of your servlet (a lifecycle method) based on the HTTP method of the request received.

If you have specifically created a servlet which handles only POST requests (uploading etc.), you'd normally override the doPost method. Any other HTTP method used to access your servlet would result in a "method not supported" exception (well technically it isn't *any* other method but you can ignore the difference for the time being).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.