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.

Recommended Answers

All 2 Replies

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).

Thank you for your reply .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.