Ejemplo n.º 1
0
 /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   HttpSession session = request.getSession();
   model.Userprofile user = (Userprofile) session.getAttribute("User");
   model.CreditInfo creditCard = getCreditInfo(user.getUserId());
   String display = confirmPurchase(user);
   request.setAttribute("display", display);
   String credit = "Enter Credit Card Number";
   String bill = "Enter Billing Address";
   String ship = "Enter Shipping Address";
   if (creditCard != null) {
     credit = String.valueOf(creditCard.getCard());
     bill = creditCard.getBillAdd();
     ship = creditCard.getShipAdd();
   }
   request.setAttribute("credit", credit);
   request.setAttribute("bill", bill);
   request.setAttribute("ship", ship);
   getServletContext().getRequestDispatcher("/Confirmation.jsp").forward(request, response);
 }
Ejemplo n.º 2
0
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession();
    model.Userprofile user = (Userprofile) session.getAttribute("User");

    int credit = Integer.parseInt(request.getParameter("credit"));
    int ccv = Integer.parseInt(request.getParameter("ccv"));
    String bill = request.getParameter("bill");
    String diffAdd = request.getParameter("diffAdd");
    String remember = request.getParameter("remember");
    String ship = request.getParameter("ship");
    model.CreditInfo creditCard = new model.CreditInfo();
    creditCard.setUserId(user.getUserId());
    creditCard.setCard(credit);
    creditCard.setSecure(ccv);
    creditCard.setBillAdd(bill);
    creditCard.setShipAdd(ship);
    System.out.println(remember);
    if (remember != null) {
      storeCreditInfo(creditCard);
    }

    getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
  }