Web >> Development >> Java Servlet >> Examples >> How to implement the same code in doPost and doGet

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class RequestInfo extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); // // Put your custome code here // } /** * We are going to perform the same operations for POST requests * as for GET methods, so this method just sends the request to * the doGet method. */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doGet(request, response); } }