But I see a message sating doPost() is not supported. The code is as follows:
Is it that there is only one to one correspondence between methods of Servlets i.e. doPost() can call only doPost() and doGet() can only call doGet().
Thanks in advance.
Why are you trying to handle a request in the doGet method if the request was the result of a post request?
I was just trying to see what could happen. No specific intention.
Within one request, yes.
The request method will stay the same for the duration of that request.
Is it a HTTP protocol limitation or this constraint is enforced to avoid some problem?
It's the way servlets work. The interface defines a method for each type of HTTP request (GET, POST, HEAD, PUT, etc..).
It also allows you to chain servlets and JSPs.
Maybe a better question would be: Why wouldn't you want this enforced? If a browser makes a get request and your first servlet passes the request to another via a dispatcher, why wouldn't you want that request to go to the second servlet's doPost method?