If i specify a GET in the action attribute of the html and define doPost() in the servlet then nothing goes wrong. Servlet is called and the service method calls the doPost().
But the vice-versa is not happening?? i.e POST in html and doGet() in servlet.
What is the logic behind this ?? what is that i am missing??
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
As you know the service method expects two parameters request and response, It uses req.getMethod() function to get the http method name. Its possible values might be Get,Post,Option,Head,Put,Delete and trace. Then it calls the corresponding function.
doGet() and doPost() have the default implementation of throwing http error that http.method_get_not_supported/http.method_post_not_supported for get and post respectively.
It is good that you got the issue resolved with your jsp yet I think this explanation would clear your understanding about how service method works and identifies which http method to call.