Hk mingham wrote:
the container will automatically choose the right http method
Yeah, that depends on the request.
The container calls the service() method. And then depending on the type of the request, service() method calls either doGet() or doPost().
You can override the service() method if you want, but it's not advisable.
Hk mingham wrote:
how do we make the right choose between dopost() or doget()?
In case you don't not the type of service and want to process both GET and POST requests in the same way, then you can write the functionality in one method and call that method from the other.
Example:
BUt it's better not to mix GET and POST - as they're made for different purposes.
GET is used to get data, it's not supposed to change anything on the server.
POST is not idempotent, data submitted in the body of POST is usually used to change something on server. For example, a transaction.