コード例 #1
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!request.isUserInRole("2")) {
      response.sendRedirect("/");
    }

    Reponse uneReponse = new Reponse();
    uneReponse.setLibelle(request.getParameter("libelle"));
    uneReponse.setEst_correct(Boolean.parseBoolean(request.getParameter("estCorrect")));
    uneReponse.setId_question(Integer.parseInt(request.getParameter("idQuestion")));

    Question question = null;

    try {
      question = QuestionService.getQuestion(Integer.parseInt(request.getParameter("idQuestion")));
    } catch (NumberFormatException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (SQLException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    try {
      ReponseService.insert(uneReponse);
      response.sendRedirect(
          "themeQuestRep?idTheme="
              + String.valueOf(question.getId_theme())
              + "&idQuestion="
              + request.getParameter("idQuestion"));
    } catch (Exception e) {
      doGet(request, response);
    }
  }