OO Programming with Java


As a complement, the following code can be integrated to the servlet to manage POST requests (coming from a form for instance).

  public void doPost(HttpServletRequest request
    , HttpServletResponse response) 
      throws IOException, ServletException {
    String name = request.getParameter("name");
    String mark = request.getParameter("mark");
    users.add(new User(name,mark));
    response.sendRedirect("./Users");
  }

NB. this code requires the User class from the next slide.