示例#1
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {
      Utilisateur utilisateur = new Utilisateur();
      utilisateur.setFirstName(request.getParameter(Parameters.PARAMETER_FIRST_NAME));
      utilisateur.setLastName(request.getParameter(Parameters.PARAMETER_LAST_NAME));
      utilisateurDao.ajouter(utilisateur);
      request.setAttribute("utilisateurs", utilisateurDao.lister());
    } catch (BeanException e) {
      request.setAttribute(Parameters.PARAMETER_ERROR, e.getMessage());
    } catch (DaoException e) {
      request.setAttribute(Parameters.PARAMETER_ERROR, e.getMessage());
    }

    this.getServletContext()
        .getRequestDispatcher("/WEB-INF/jsp/sql/sQLWithDAO.jsp")
        .forward(request, response);
  }
示例#2
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      request.setAttribute(Parameters.PARAMETER_USERS, utilisateurDao.lister());
    } catch (DaoException e) {
      request.setAttribute(Parameters.PARAMETER_ERROR, e.getMessage());
    }

    this.getServletContext()
        .getRequestDispatcher("/WEB-INF/jsp/sql/sQLWithDAO.jsp")
        .forward(request, response);
  }