/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    // get type
    String type = request.getParameter("type");

    if (type.equals("showdetail")) {

      // get goods id
      String goodsID = request.getParameter("id");
      // to call googsbeanBO
      GoodsBeanBO gbb = new GoodsBeanBO();
      GoodsBean gb = gbb.getGoodsBean(goodsID);
      request.setAttribute("goodsinfo", gb);

      request.getRequestDispatcher("showDetail.jsp").forward(request, response);

    } else if (type.equals("showpage")) {

      // get page now
      String pageNow = request.getParameter("pageNow");

      request.getRequestDispatcher("index.jsp?s_pageNow=" + pageNow).forward(request, response);
    }
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PagamentoDao cc = new PagamentoDao();
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    String n = request.getParameter("bandeira");
    String p = request.getParameter("numero");
    String f = request.getParameter("codigo");
    String g = request.getParameter("data");
    String k = request.getParameter("cpf");

    HttpSession session = request.getSession(false);
    if (session != null) session.setAttribute("name", n);

    try {
      if (cc.validate(n, p, f, g, k)) {
        RequestDispatcher rd = request.getRequestDispatcher("pagamentosucesso.jsp");
        rd.forward(request, response);
      } else {
        out.print("<p style=\"color:red\">Pagamento não aceito</p>");
        RequestDispatcher rd = request.getRequestDispatcher("pagamentocredito.jsp");
        rd.include(request, response);
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    out.close();
  }
  /** Implementacao do metodo doPost() Servlet de Autenticacao de Usuario. */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    HttpSession session = request.getSession(); // obtem a sessao do usuario, caso exista
    UsuarioBC usuarioBC = new UsuarioBC();
    Usuario user = null;
    String email_form = request.getParameter("email"); // Pega o email vindo do formulario
    String senha_form = request.getParameter("senha"); // Pega a senha vinda do formulario
    Boolean saudacao = false;

    try {
      user = usuarioBC.consultarUsuarioPorEmail_Senha(email_form, senha_form);
    } catch (Exception e) {

    }

    // se nao encontrou usuario no banco, redireciona para a pagina de login
    if (user == null) {
      session.setAttribute("erro", "E-mail ou Senha inválidos!");
      request.getRequestDispatcher("/login.jsp").forward(request, response);
    } else {
      saudacao = true;
      // se o dao retornar um usuario, coloca o mesmo na sessao
      session.setAttribute("usuarioLogado", user);
      session.setAttribute("saudacao", saudacao);
      request.getRequestDispatcher("/index.jsp").forward(request, response);
    }
  }
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String back = (String) request.getSession().getAttribute("backTOURL");
    request.getSession().removeAttribute("backTOURL");
    if (validateForm(request) == true) {
      try {
        String codProd = request.getParameter("prod");
        String comentario = request.getParameter("comentario");
        Tools.validateHTML(comentario);
        PersistenceInterface persistencia =
            (PersistenceInterface) request.getServletContext().getAttribute("persistence");
        Usuario user = persistencia.getUser((String) request.getSession().getAttribute("usuario"));

        boolean ok =
            persistencia.newComment(user, codProd, Tools.generaUUID(), Tools.getDate(), comentario);
        if (!ok) {
          request.setAttribute("resultados", "Error en la operación");
          Tools.anadirMensaje(request, "Ha ocurrido un error en el transcurso de la operación");
          request.getRequestDispatcher("/shop/viewprod.jsp?" + back).forward(request, response);
        } else {
          response.sendRedirect("/shop/viewprod.jsp?" + back);
        }
      } catch (IntrusionException ex) {
        request.setAttribute("resultados", "HTML no válido");
        Tools.anadirMensaje(request, ex.getMessage());
        request.getRequestDispatcher("/shop/viewprod.jsp?" + back).forward(request, response);
      }
    } else {
      request.setAttribute("resultados", "Formulario enviado incorrecto");
      Tools.anadirMensaje(request, "El formulario que ha enviado no es correcto");
      request.getRequestDispatcher("/shop/viewprod.jsp?" + back).forward(request, response);
    }
  }
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub

    if (request.getSession(false) != null) {
      request.getRequestDispatcher("/acesso.do").forward(request, response);
    }
    Professor professor = (Professor) Fachada.getInstance().criarProfessor();
    professor.setLogin(request.getParameter("login"));
    professor.setNome(request.getParameter("nome"));
    professor.setSobrenome(request.getParameter("sobrenome"));
    professor.setEmail(request.getParameter("email"));
    professor.setSenha(request.getParameter("senha"));
    professor = Fachada.getInstance().cadastrarProfessor(professor);
    String[] materias = request.getParameterValues("disciplinas");
    if (materias != null) {
      for (int x = 0; x < materias.length; x++) {
        Disciplina disciplina = (Disciplina) Fachada.getInstance().criarDisciplina();
        Disciplina disciplinaRetornada = null;
        disciplina.setDescricao(materias[x]);

        disciplinaRetornada = comparaDisciplinas(disciplina);
        disciplinaRetornada.setProfessor(professor);
        Fachada.getInstance().atualizarDisciplina(disciplinaRetornada);
      }
    }

    request.getRequestDispatcher("/acesso.do").forward(request, response);
  }
Esempio n. 6
0
  /**
   * Handles the HTTP <code>GET</code> method.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    int idCompetencia = Integer.parseInt(request.getParameter("idCompetencia"));
    String nombre = request.getParameter("nombre");
    RequestDispatcher view = null;
    Criterios c = new Criterios();
    CriterioCompetencia cc = new CriterioCompetencia();
    ArrayList CriterioCompetencia = new ArrayList();
    ArrayList Criterios = new ArrayList();

    try {
      CriterioCompetencia = cc.obtenerCriterioxCompetencia(idCompetencia);
      // Criterios = c.obtenerCriteriosxCompetencia(idCompetencia);
      Criterios = c.obtenerCriterios();
      if (CriterioCompetencia != null) {
        request.setAttribute("CriterioCompetencia", CriterioCompetencia);
        request.setAttribute("Criterios", Criterios);
        request.setAttribute("idCompetencia", idCompetencia);
        request.setAttribute("nombre", nombre);
        view = request.getRequestDispatcher("agregarCriterios.jsp");
      } else {
        view = request.getRequestDispatcher("../error.jsp");
      }
      view.forward(request, response);
    } catch (Exception ex) {
      System.out.println(ex);
    }
  }
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");

    String login = request.getParameter("login");
    String email = request.getParameter("email");
    String approuve = request.getParameter("approuve"); // "on" si cochée sinon ""

    if (checkMail(email) && checkLogin(login) && checkApprouve(approuve)) {
      request.getRequestDispatcher("adhesionOkServlet").forward(request, response);
    } else {
      // Renvoyer les paramètres pour les réafficher
      request.setAttribute("login", login);
      request.setAttribute("email", email);
      request.setAttribute("approuve", approuve);

      // gestion du message d'erreur
      if (!checkLogin(login))
        request.setAttribute("wrongLogin", "Login trop court (5 caractères min)");
      if (!checkMail(email)) request.setAttribute("wrongEmail", "Email non conforme");
      if (!checkApprouve(approuve))
        request.setAttribute("wrongApprouve", "Veuillez cocher les conditions générale svp");

      request.getRequestDispatcher("/adhesion.jsp").forward(request, response);
    }
  }
 protected void loginRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   if (!request.getSession().equals(null)) {
     request.getSession().invalidate();
   }
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   String userID = request.getParameter("userID");
   String pass = request.getParameter("pass");
   String table = "admin";
   /*int role = user.getRole();
     	out.println(user.toString());
     	out.println(userID);
     	out.println(pass);
   out.println(user.getRole());
   out.println(user.getUserID());
   out.println(isAuth);*/
   if (loginService.isAuthenticate(userID, pass, table)) {
     RequestDispatcher rd = request.getRequestDispatcher("adminhomepage.html");
     rd.forward(request, response);
   } else {
     out.print("<p style=\"color:red\" id = \"alert\">UserID or Password is not correct!</p>");
     RequestDispatcher rd = request.getRequestDispatcher("adminloginpage.html");
     rd.include(request, response);
   }
   out.close();
 }
Esempio n. 9
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException, SQLException, ClassNotFoundException,
          NumberFormatException {
    response.setContentType("text/html;charset=UTF-8");
    SQLpooler sqlpooler = new SQLpooler();
    Connection conn = sqlpooler.makeMyConnection();
    try {
      String notes = request.getParameter("ecost");
      int appid = Integer.parseInt(request.getParameter("appid").trim());
      String sql =
          "update appointments set extracost = '" + notes + "' where appointmentid = " + appid;
      PreparedStatement preStatement = conn.prepareStatement(sql);
      ResultSet result = preStatement.executeQuery();
      HttpSession session = request.getSession(true);
      request.setAttribute("ecost", "EXTRA COST ADDED");
      request.getRequestDispatcher("/doctormain.jsp").forward(request, response);

    } catch (SQLException se) {
      request.setAttribute("ecost", "invalid data");
      request.getRequestDispatcher("/doctormain.jsp").forward(request, response);

    } finally {
      conn.close();
    }
  }
Esempio n. 10
0
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String username = req.getParameter("username");
    String password = req.getParameter("password");

    Map<String, String> messages = new HashMap<String, String>();
    req.setAttribute("messageMap", messages);

    if (username.isEmpty() || password.isEmpty()) {
      messages.put("fieldIsEmpty", "Fields cannot not be empty");
      req.getRequestDispatcher("login.jsp").forward(req, resp);
    }

    user = userService.getUser(username);

    if (user.getPassword().equals(password)) {
      req.setAttribute("name", username);
      HttpSession session = req.getSession();
      session.setAttribute("username", username);
      req.getRequestDispatcher("index.jsp").forward(req, resp);
    } else {
      messages.put("noUser", "This user is not registered. Please use link below to register!");
      req.getRequestDispatcher("login.jsp").forward(req, resp);
    }
  }
Esempio n. 11
0
  // Service the request
  public void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    // check if the actor has logon
    if (!RightManager.hasLogon(request)) {
      RequestDispatcher rd = request.getRequestDispatcher(JSP_IS_LOGIN);
      rd.forward(request, response);
      return;
    }

    // do action
    String action = request.getParameter(GETATTR_ACTION);
    String resultPage = ERROR_JSP;
    if (action == null || action.equalsIgnoreCase(A_LISTUGRIGHT)) {
      resultPage = listUserGroupRight(request, response);
    }
    //		else if ( action.equalsIgnoreCase(A_SAVE) ){
    //			resultPage = saveUserGroupRight(request,response);
    //		}

    //        Log.print(" =============================== ResultPage is : "+resultPage);

    RequestDispatcher rd = request.getRequestDispatcher(resultPage);
    rd.forward(request, response);
  }
Esempio n. 12
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    if (request.getSession().getAttribute("account") == null) {
      request.getRequestDispatcher("/login.jsp").forward(request, response);
      return;
    }

    String client_id = request.getParameter("client_id");

    Client client = null;

    try {
      client = client_service.findClientById(client_id);
    } catch (DAOException e) {
      PageStatus status =
          new PageStatus("Client", "Error: \n Database Error!", "/425pj/ClientManage");
      request.setAttribute("page_status", status);
      request
          .getRequestDispatcher("/WEB-INF/pages/status/update_fail.jsp")
          .forward(request, response);
      return;
    }

    request.setAttribute("client", client);
    request
        .getRequestDispatcher("/WEB-INF/pages/client/client_update.jsp")
        .forward(request, response);
  }
 /**
  * This method manages a request from the user. Here, the decision of moving forward or staying
  * still is made. This depends on the users credentials and whether they check out or not.
  *
  * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   // A few details that are relevant to checking.
   Model model = new Model();
   String username = request.getParameter("username");
   String password = request.getParameter("password");
   boolean result = model.login(username, password);
   RequestDispatcher dispatcher;
   HttpSession session = request.getSession();
   // If the user credentials are correct
   if (result) {
     String userIDKey = new String("userID");
     String userID = new String(username);
     // Session management
     session.setAttribute(userIDKey, userID);
     session.setAttribute("model", model);
     session.setAttribute("status", "");
     session.setMaxInactiveInterval(60);
     // Moving on to the next view.
     dispatcher = request.getRequestDispatcher("createMail.jsp");
   }
   // If the user credentials are incorrect
   else {
     model.close();
     // Session management and view control.
     session.setAttribute("statusLog", "Login failed. Could you please try again?");
     dispatcher = request.getRequestDispatcher("index.jsp");
   }
   dispatcher.forward(request, response);
 }
Esempio n. 14
0
  /** Check CB values and the date (after today) */
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse resp)
      throws ServletException, IOException {
    String numCB = request.getParameter("numCB");
    String cryptogramme = request.getParameter("cryptogramme");

    try {
      SimpleDateFormat formatter = new SimpleDateFormat("MM/yy");
      Date endValidation = formatter.parse(request.getParameter("endValidation"));

      Date today = new Date();

      if (numCB != null
          && cryptogramme != null
          && endValidation != null
          && today.compareTo(endValidation) < 0) {
        // paiement accepté //
        request.getSession().setAttribute("shoppingCart", new ArrayList<Product>());
        request.setAttribute(
            "paymentState",
            "Votre paiement a bien été effectué. Merci d'avoir utilisé cette application.");
        request.getRequestDispatcher("paymentFinished.jsp").forward(request, resp);
      } else {
        // paiement refusé //
        request.setAttribute("paymentState", "Votre paiement a été refusé.");
        request.getRequestDispatcher("paymentFinished.jsp").forward(request, resp);
      }

    } catch (ParseException ex) {
      System.err.println(ex.getMessage());
      resp.sendRedirect("payment");
    }
  }
Esempio n. 15
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    req.setCharacterEncoding("UTF-8");

    searchContent = req.getParameter("searchContent");

    System.out.println("search content: " + searchContent);

    if (searchContent.trim().equals("")) {
      req.getRequestDispatcher("/search.jsp").forward(req, resp);
    }

    // queryStr = "教育部重点实验室评估";

    queryService = new QueryService(searchContent);

    try {
      resultList = queryService.excuteQuery();
      req.setAttribute("resultList", resultList);
      req.setAttribute("searchContent", searchContent);
      req.getRequestDispatcher("/search.jsp").forward(req, resp);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 16
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    request.setCharacterEncoding("UTF-8");

    HttpSession session = request.getSession();
    String subject = request.getParameter("subject");
    String course = new String(request.getParameter("course").getBytes("iso-8859-1"), "utf-8");
    course = "(" + course + ")";
    Studentinfo studentinfo = (Studentinfo) session.getAttribute("user");
    subject = course + studentinfo.getName() + ":" + subject;

    String content = request.getParameter("content");
    String emailAddr = "\n\n\n 发信者邮箱地址:" + studentinfo.getEmail();
    content = content + emailAddr;

    String t_id = request.getParameter("to");
    TeacherinfoDAO teacherinfoDAO = new TeacherinfoDAO();
    Teacherinfo teacherinfo = teacherinfoDAO.findById(t_id);
    String to = teacherinfo.getEmail();

    SendMailServlet sendMailServlet = new SendMailServlet();
    if (!sendMailServlet.sendMail(to, subject, content)) {
      request.getRequestDispatcher("EmailFailure.html").forward(request, response);
    } else {
      request.getRequestDispatcher("EmailSuccess.html").forward(request, response);
    }
  }
Esempio n. 17
0
  private void doProcessing(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    RequestDispatcher disp;
    String pageNum = req.getParameter("page");
    String button = req.getParameter("button1");

    if (pageNum == null) {

      disp = req.getRequestDispatcher("home.jsp");
      disp.forward(req, resp);

    } else if (pageNum.equals("2")) {
      BasketBean b = new BasketBean();
      try {
        b.addOrderToDatabase(req);
      } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (button != null) {

      if (req.getSession() != null) req.getSession().invalidate();
      req.getRequestDispatcher("login.jsp").forward(req, resp);
      return;
    }
  }
Esempio n. 18
0
 /**
  * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   String url = request.getParameter("url_req");
   String user = request.getParameter("username");
   String password = request.getParameter("password");
   String[] remember = request.getParameterValues("cookie");
   try {
     User u = RegistrationManager.verifyUser(user, password);
     if (u != null) {
       if (!u.getProfile().equals(RegistrationManager.NO_PROFILES)) {
         request.getSession().setAttribute("user", u);
         if (remember != null) {
           Cookie cookie = new Cookie("user", user);
           cookie.setMaxAge(30 * 24 * 60 * 60); // 1 month.
           cookie.setPath("/");
           response.addCookie(cookie);
         }
         u.updateLastAccess(user);
         if (url.equals("null")) response.sendRedirect("index.jsp");
         else response.sendRedirect(url);
       } else {
         request.setAttribute(
             StringConstants.MESSAGE_ATTRIBUTE, StringConstants.MESSAGE_DOMAIN_ERROR);
         request.getRequestDispatcher("login.jsp").forward(request, response);
       }
     } else {
       request.setAttribute(StringConstants.MESSAGE_ATTRIBUTE, StringConstants.MESSAGE_ERROR);
       request.getRequestDispatcher("login.jsp").forward(request, response);
     }
   } catch (IOException | ServletException e) {
     request.setAttribute(StringConstants.MESSAGE_ATTRIBUTE, StringConstants.MESSAGE_ERROR_SERVER);
     request.getRequestDispatcher("login.jsp").forward(request, response);
   }
 }
Esempio n. 19
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    String action = getAction(req);
    System.out.println(action);
    if (action.startsWith("/categories")) {

      CategoriesDAO categoriesDAO = new CategoriesDAO();
      List<Category> categories = categoriesDAO.getAllCategories();

      req.setAttribute("categories", categories);

      req.getRequestDispatcher("categories.jsp").forward(req, resp);
    } else if (action.equals("/projects")) {
      int categoryId = Integer.valueOf(req.getParameter("category"));

      ProjectDAO projectDAO = new ProjectDAO();
      List<Project> projects = projectDAO.getListProjectByCategoryId(categoryId);

      req.setAttribute("projects", projects);

      req.getRequestDispatcher("projects.jsp").forward(req, resp);
    } else if (action.equals("/project")) {
      int projectId = Integer.valueOf(req.getParameter("project"));

      ProjectDAO projectDAO = new ProjectDAO();
      // Project project = projectDAO.getProjectById(projectId,categoryId);

      // req.setAttribute("project", project);

      req.getRequestDispatcher("project.jsp").forward(req, resp);
    }
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    String adminUser = request.getParameter("adminUser");
    String adminPassword = request.getParameter("adminPassword");

    if (Validation.isEmpty(adminUser) && Validation.isEmpty(adminPassword)) {
      request.setAttribute("adminname", adminUser);
      request.setAttribute("adminpassword", adminPassword);
      request.getRequestDispatcher("index.jsp").forward(request, response);
    } else {
      AdminLoginBean alb = new AdminLoginDAO().login(adminUser, adminPassword);
      if (alb != null) {
        System.out.println("here");

        System.out.println(adminUser + "===" + "np");

        session = request.getSession();
        session.setAttribute("admin", adminUser);
        session.setMaxInactiveInterval(6000);
        System.out.println(session.getAttribute("admin"));
        System.out.println("Session Created");
        response.sendRedirect("DashBoardList");
      } else {
        System.out.println("Login Failed");
        request.setAttribute(
            "authentication", "<font color=red>*userName or password is invalid</font>");
        request.getRequestDispatcher("index.jsp").forward(request, response);
      }
    }
  }
  // 查询
  public void list4this(HttpServletRequest request, HttpServletResponse response) throws Exception {
    //		super.list(request,response);

    // 查询
    PaginationObj domainPagination =
        getDomainDao()
            .searchPaginationByDomainInstance(
                domainInstance,
                domainInstance.findDefaultOrderBy(),
                domainSearchCondition.getPageNo(),
                domainSearchCondition.getPageCount());

    request.setAttribute(DOMAIN_INSTANCE, domainInstance);
    request.setAttribute(DOMAIN_PAGINATION, domainPagination);

    // 转向
    if ("true".equalsIgnoreCase(request.getParameter("4m"))) {
      request
          .getRequestDispatcher("/" + getBasePath() + "/" + BASE_METHOD_LIST + "4m.jsp")
          .forward(request, response);
    } else if ("true".equalsIgnoreCase(request.getParameter("justListData"))) {
      request
          .getRequestDispatcher("/" + getBasePath() + "/" + BASE_METHOD_LIST + "Data.jsp")
          .forward(request, response);
    } else {
      request
          .getRequestDispatcher("/" + getBasePath() + "/" + BASE_METHOD_LIST + ".jsp")
          .forward(request, response);
    }
  }
Esempio n. 22
0
 /** *******************图书归还********************** */
 private void bookback(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   // 查询读者信息
   readerForm.setBarcode(request.getParameter("barcode"));
   ReaderForm reader = (ReaderForm) readerDAO.queryM(readerForm);
   request.setAttribute("readerinfo", reader);
   // 查询读者的借阅信息
   request.setAttribute("borrowinfo", borrowDAO.borrowinfo(request.getParameter("barcode")));
   if (request.getParameter("id") != null) {
     int id = Integer.parseInt(request.getParameter("id"));
     String operator = request.getParameter("operator");
     if (id > 0) { // 执行归还操作
       int ret = borrowDAO.back(id, operator);
       if (ret == 0) {
         request.setAttribute("error", "图书归还失败!");
         request.getRequestDispatcher("error.jsp").forward(request, response);
       } else {
         request.setAttribute("bar", request.getParameter("barcode"));
         request.getRequestDispatcher("bookBack_ok.jsp").forward(request, response);
       }
     }
   } else {
     request.getRequestDispatcher("bookBack.jsp").forward(request, response);
   }
 }
Esempio n. 23
0
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    Session session = RequestAdapter.getSession(request);

    TaskDAOIf taskDAO = DAOFactory.TaskDAOIf(session);
    Task task = taskDAO.getTask(Util.parseInteger(request.getParameter("taskid"), 0));
    if (task == null) {
      request.setAttribute("title", "Aufgabe nicht gefunden");
      request.getRequestDispatcher("MessageView").forward(request, response);
      return;
    }

    // check Lecture Participation
    ParticipationDAOIf participationDAO = DAOFactory.ParticipationDAOIf(session);
    Participation participation =
        participationDAO.getParticipation(
            RequestAdapter.getUser(request), task.getTaskGroup().getLecture());
    if (participation == null
        || participation.getRoleType().compareTo(ParticipationRole.ADVISOR) != 0) {
      response.sendError(HttpServletResponse.SC_FORBIDDEN, "insufficient rights");
      return;
    }

    if (task.getDeadline().after(Util.correctTimezone(new Date()))
        || task.getShowPoints() != null) {
      request.setAttribute("title", "Ungültige Anfrage");
      request.getRequestDispatcher("MessageView").forward(request, response);
      return;
    }

    request.setAttribute("task", task);
    request.getRequestDispatcher("PublishGradesView").forward(request, response);
  }
Esempio n. 24
0
  /** *******************图书借阅********************** */
  private void bookborrow(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // 查询读者信息
    readerForm.setBarcode(request.getParameter("barcode"));
    ReaderForm reader = (ReaderForm) readerDAO.queryM(readerForm);
    request.setAttribute("readerinfo", reader);
    // 查询读者的借阅信息
    request.setAttribute("borrowinfo", borrowDAO.borrowinfo(request.getParameter("barcode")));
    // 完成借阅
    String f = request.getParameter("f");
    String key = request.getParameter("inputkey");
    if (key != null && !key.equals("")) {
      String operator = request.getParameter("operator");
      BookForm bookForm = bookDAO.queryB(f, key);
      if (bookForm != null) {
        int ret = borrowDAO.insertBorrow(reader, bookDAO.queryB(f, key), operator);
        if (ret == 1) {
          request.setAttribute("bar", request.getParameter("barcode"));
          request.getRequestDispatcher("bookBorrow_ok.jsp").forward(request, response);

        } else {
          request.setAttribute("error", "添加借阅信息失败!");
          request.getRequestDispatcher("error.jsp").forward(request, response);
        }
      } else {
        request.setAttribute("error", "没有该图书!");
        request.getRequestDispatcher("error.jsp").forward(request, response);
      }
    } else {
      request.getRequestDispatcher("bookBorrow.jsp").forward(request, response);
    }
  }
  /**
   * Handles the HTTP <code>POST</code> method.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    //    processRequest(request, response);

    response.setContentType("text/html");

    String userName = request.getParameter("UserName");
    String password = request.getParameter("Password");
    HttpSession session = request.getSession(false);
    //  if(session!=null)
    //  session.setAttribute("name", userName);

    if (DonorLoginImpl.validate(userName, password)) {
      out.print("Welcome, " + userName);
      session = request.getSession();
      session.setAttribute("name", userName);
      RequestDispatcher rd = request.getRequestDispatcher("/WelcomeDonor.jsp");
      // out.print("Welcome, "+userName);
      rd.forward(request, response);

    } else {
      out.print("<p style=\"color:red\">Sorry username or password error</p>");
      RequestDispatcher rd = request.getRequestDispatcher("/Donor.jsp");
      rd.include(request, response);
    }

    out.close();
  }
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

    Model model = new Model();

    String order = null;
    order = request.getParameter("placeOrder");

    System.out.println(order);

    if (order != null) {
      model.calculateOrder(request);
      request.setAttribute("orderSubTotal", model.getOrderSubTotal());
      request.setAttribute("orderGrandTotal", model.getOrderGrandTotal());
      request.setAttribute("tax", model.getTax());
      request.setAttribute("menu", model.getMenuSelection());
      RequestDispatcher view = request.getRequestDispatcher("Bill.jsp");

      view.forward(request, response);
    } else {
      HashMap<String, String> menu = model.getMenuOptions();

      request.setAttribute("menu", menu);
      RequestDispatcher view = request.getRequestDispatcher("MenuCheckboxes.jsp");

      view.forward(request, response);
    }
  }
Esempio n. 27
0
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    final CreationClientForm form = new CreationClientForm(req);
    req.setAttribute(RequestConstants.FORM_CREATION_CLIENT, form);
    form.validate();

    if (form.hasErrors()) {
      req.setAttribute("msgError", LangUtil.getMessage(req.getLocale(), "error.form"));
      req.getRequestDispatcher("jsp/creerClient.jsp").forward(req, resp);
    } else {
      final ClientDTO client =
          (ClientDTO)
              ConverterFactory.getInstance()
                  .getFormConverter(ClientFormConverter.class.getName())
                  .convertToDTO(form);

      // TODO revoir avec les BDD
      final String idClient = client.getNom();
      Map<String, ClientDTO> mapClients =
          (Map<String, ClientDTO>) req.getSession().getAttribute(SessionConstants.MAP_CLIENTS);
      if (mapClients == null) {
        mapClients = new HashMap<String, ClientDTO>();
        req.getSession().setAttribute(SessionConstants.MAP_CLIENTS, mapClients);
      }
      mapClients.put(idClient, client);

      req.setAttribute(RequestConstants.CURRENT_CLIENT, client);

      req.getRequestDispatcher("jsp/afficherClient.jsp").forward(req, resp);
    }
  }
Esempio n. 28
0
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub

    try {

      Usuario u =
          AdaptadorUsuario.getOne(
              request.getParameter("txtUsuario"), request.getParameter("txtPass"));
      if (u != null) {

        request.getSession().setAttribute("Usuario", u.getUsuario());
        request.getSession().setAttribute("Contraseña", u.getContraseña());
        request.getSession().setAttribute("TipoUsuario", u.getTipoUsuario());

        request.getRequestDispatcher("/Inicio.jsp").forward(request, response);

      } else {
        request.setAttribute("EstadoLogin", "Usuario y/o contraseña incorrectos");
        request.getRequestDispatcher("/Login.jsp").forward(request, response);
      }

    } catch (Exception ex) {
      request.setAttribute("Error", "Hubo un problema al iniciar sesión. Intente más adelante");
      request.getRequestDispatcher("/Error.jsp").forward(request, response);
    }
  }
Esempio n. 29
0
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html;charset=utf-8");
    PrintWriter out = response.getWriter();
    if (request.getParameter("action") != null) {
      this.action = request.getParameter("action");
      if (action.equals("add")) // 添加商品进购物车
      {
        if (addToCart(request, response)) {
          request.getRequestDispatcher("/success.jsp").forward(request, response);
        } else {
          request.getRequestDispatcher("/failure.jsp").forward(request, response);
        }
      }

      if (action.equals("show")) // 显示购物车
      {
        request.getRequestDispatcher("/cart.jsp").forward(request, response);
      }

      if (action.equals("delete")) // 如果是执行删除购物车中的商品
      {
        if (deleteFromCart(request, response)) {
          request.getRequestDispatcher("/cart.jsp").forward(request, response);
        } else {
          request.getRequestDispatcher("/cart.jsp").forward(request, response);
        }
      }
    }
  }
Esempio n. 30
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("html/text");
    PrintWriter out = response.getWriter();

    String viewitem = request.getParameter("name");
    System.out.println(viewitem);
    UserDAO userDAO = new UserDAO();
    boolean isertDummyItemsOrNot = false;

    if (userDAO.itemCount() > 0) {
      isertDummyItemsOrNot = true;
    } else {
      isertDummyItemsOrNot = userDAO.insertDummyItems();
    }

    if (isertDummyItemsOrNot) {
      Item it = userDAO.itemFatch(viewitem);
      System.out.println("Heloo " + it);
      request.setAttribute("abc", it.getItemID());
      request.setAttribute("bcd", it.getItemName());
      request.setAttribute("efc", it.getPrice());
      request.setAttribute("img", (String) hm.get(it.getItemID()));
      RequestDispatcher rd = request.getRequestDispatcher("Item.jsp");
      rd.forward(request, response);
    } else {
      RequestDispatcher rd = request.getRequestDispatcher("ItemDesc.jsp");
      rd.forward(request, response);
      System.out.println("no");
    }
  }