Can any one tell me that " if i am calling a servlet from a html/jsp page how servlet decides which method needs to call. i mean if i have given GET as a method in html/jsp form it calls doGet() why? and if i override service() method and i dont have doGet or doPost.it is calling service() method why?
Thnaks in advance
When you invoke a servlet, the service() method is always called. This is the base method for servlet processing.
The default service() method in the HttpServlet class calls doGet(), doPost(), etc., based on the method of the HTTP request. Therefore, if you don't override the default service() method, the appropriate doXXX() method also gets called. If you do override the service() method, you are replacing this functionality, and only your overridden service() method is invoked.
BTW, you can tell what the HTTP method is, based on how you link to the servlet. Hyperlinks (<a> tags) and redirects always use the GET method, while <form> tags use GET or POST, depending on what you specify in the action attribute.