HI I am swetha iam confused when to use service(), doget(), dopost() method in servlets
Any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
When you invoke a Servlet, the servlet engine passes the information on to the Servlets service() method. This method determines the type of request made (GET, POST) and calls the function do*, like doGet, doPost. GET and POST just differ in the way form data is sent from the browser to the server. The method doGet handles data that has been attached to the url in the form url ?(name=value ampersand)+. With the doPost method, form data comes in through standard input stream, a cgi would just need to open the input stream and read until EOF to get the form data.
You should use doGet() when you want to intercept on HTTP GET requests. It is used to preprocess a request. You should use doPost() when you want to intercept on HTTP POST requests.It is used to postprocess a request.