Package cart

Examples of cart.ShoppingCart


  {
    boolean orderCompleted = true;
    // Get the user's session and shopping cart
    HttpSession session = request.getSession(true);
    ResourceBundle messages = (ResourceBundle)session.getAttribute("messages");
    ShoppingCart cart =
      (ShoppingCart)session.getAttribute("cart");
    if (cart == null) {
      cart = new ShoppingCart();
      session.setAttribute("cart", cart);
    }
    // Update the inventory
    try {
      bookDB.buyBooks(cart);
View Full Code Here


      String clear = null;
      BookDetails book = null;
      BookDBAO bookDBAO = (BookDBAO)getServletContext().getAttribute("bookDBAO");
      HttpSession session = request.getSession();
      String selectedScreen = request.getServletPath();
      ShoppingCart cart = (ShoppingCart)session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
      }
      if (selectedScreen.equals("/bookcatalog")) {
        bookId = request.getParameter("Add");
        if (!bookId.equals("")) {
          try {
            book = bookDBAO.getBookDetails(bookId);
            cart.add(bookId, book);
          } catch (BookNotFoundException ex) {
            // not possible
          }
        }
      } else if (selectedScreen.equals("/bookshowcart")) {
        bookId =request.getParameter("Remove");
        if (bookId != null) {
           cart.remove(bookId);         
        }
       
        clear = request.getParameter("Clear");
        if (clear != null && clear.equals("clear")) {
           cart.clear();
        }

      } else if (selectedScreen.equals("/bookreceipt")) {
      // Update the inventory
        try {
View Full Code Here

      String clear = null;
      BookDBAO bookDBAO = (BookDBAO)getServletContext().getAttribute("bookDBAO");

      HttpSession session = request.getSession();
      String selectedScreen = request.getServletPath();
      ShoppingCart cart = (ShoppingCart)session.getAttribute("cart");

      if (cart == null) {

        cart = new ShoppingCart();

        session.setAttribute("cart", cart);
      }

      if (selectedScreen.equals("/bookcatalog")) {
        bookId = request.getParameter("Add");
        if (!bookId.equals("")) {
          try {
            book = bookDBAO.getBookDetails(bookId);
            if ( book.getOnSale() ) {
              double sale = book.getPrice() * .85;
              Float salePrice = new Float(sale);
              book.setPrice(salePrice.floatValue());
            }
            cart.add(bookId, book);
          } catch (BookNotFoundException ex) {
            // not possible
          }
        }
      } else if (selectedScreen.equals("/bookshowcart")) {
        bookId =request.getParameter("Remove");
        if (bookId != null) {
          cart.remove(bookId);
        }
       
        clear = request.getParameter("Clear");
        if (clear != null && clear.equals("clear")) {
           cart.clear();
        }

      } else if (selectedScreen.equals("/bookreceipt")) {
      // Update the inventory

View Full Code Here

TOP

Related Classes of cart.ShoppingCart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.