class UserUpdateServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
        User updatedUser = new User(
                req.getParameter("name"),
                req.getParameter("login"),
                req.getParameter("email"),
                req.getParameter("role"),
                req.getParameter("password")
        );
        updatedUser.setCity(req.getParameter("city"));
        updatedUser.setCountry(req.getParameter("country"));
        updatedUser.setId(Integer.parseInt(req.getParameter("id")));
        String message = "";
        String error = "";
        if (this.validator.update(updatedUser)) {
            message = "User successfully updated";
        } else {
            error = "User not updated";
        }
        req.setAttribute("message", message);
        req.setAttribute("error", error);
        try {
            req.setAttribute("users", this.validator.findAll());
            req.getRequestDispatcher("/WEB-INF/views/users.jsp").forward(req, resp);
        } catch (ServletException | IOException e) {
           LOG.error(e.getMessage(), e);
        }
    }

}