# Web Development > JSP doget method instead of doPost

## gptnitesh

Suppose I am calling doPost method from the html but there is no such method defined in servlet in place of doPost method we define doget method then what will happen?

----------


## rajeshnarkhed

well..a good question i would say  :Big Grin:  and i was asked the same thing in one of my JAVA tech interviews..and I answered it  :Wink: 

If you implement only doGET() and dont implement doPOST() then all the POST requests for such a servlet are rejected by the servlet container giving error back to the client which (might) say 405 Resource not found.

Later on, I tested the same with resin web container and found that i was right.
I guess the error messages might differ from one web container to another, but the end result i.e. request rejection will always happen as mentioned above.

Following excerpt from resin webpage says:
Error 405 resource not found

Usually, this is a servlet extending HttpServlet and implementing doGet but not doPost. If you send a POST request, like a form, to a servlet that only implements doGet, you will get 405 resource not found. 

Also this http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=019923 says:

"the doXXX methods are called by service() method which in turn is called by the container (tomcat for example) , the service() mehtod will always be called when ever a request comes to the container for a resource(servlet) but by allowing you to implement the doXXX() methods , the container gives you the power to accept or reject particular types of requets , for example if you implement only doGET then the Post requests will not be processed and vice versa."

Hope this helps!

----------

