In this tutorial, we will create a simple HTML page which sends a POST request, including a username and a password to the “HelloWorld” servlet. The “HelloWorld” servlet will printout the received information.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String userName = request.getParameter("username"); String password = request.getParameter("password"); response.setContentType("text/html"); PrintWriter pw = response.getWriter(); pw.println("<h2>"); pw.println("Username: "+userName); pw.println("</h2><h2>"); pw.println("Inputed password: "+password); pw.println("</h2>"); pw.println(""); }