In servlet program we are calling the doGet()
or doPost()
method but in the servlet life cycle says that all requests will be redirected to s
The service() method detects the HTTP method used and delegates to doGet(), doPost() and other methods which process HTTP requests in a HTTPServlet. It also encapsulates the ServletRequest and ServletResponse objects in HttpServletRequest and HttpServletResponse objects which contain additional context data from the HTTP headers.
You never really call doGet() or doPost() (the service() method will, and it is called by the Web container as you read in the lifecycle). You should also not override the service() method if you are writing an HTTPServlet.