protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        BookService bookService = (BookService) getServletContext().getAttribute("bookService");//呼叫service

        int booksCount = bookService.getBooksCount();//取得book總數
        int size = 10;
        int page = 1;//此變數名稱固定在getBooksPages()方法裡
        
        if (request.getParameter("size") != null &&request.getParameter("page") != null) {//檢查目前page,size
            page = Integer.parseInt(request.getParameter("page"));
            size = Integer.parseInt(request.getParameter("size"));
        } else if (request.getSession().getAttribute("page") != null && request.getSession().getAttribute("size") != null) {
            page = (int) request.getSession().getAttribute("page");//從session找page,size
            size = (int) request.getSession().getAttribute("size");
        }
        request.getSession().setAttribute("page", page);
        request.getSession().setAttribute("size", size);

        List<StringBuilder> pages = getBooksPages("ShowBookStore.view", booksCount, size);//計算需要頁面且回傳超連結
        Set<Book> bookSet = bookService.getAllBook(Math.min(page, pages.size()), size);//根據page與size查找資料庫book,page不超過size
//               request.getSession().setAttribute("page", page);
//          request.getSession().setAttribute("size", size);
        request.setAttribute("booksPage", bookSet);//反正每次都要查新的,不用活太久
        request.setAttribute("pagesCount", pages);

//購物session檢查
        HttpSession session = request.getSession();
        if (session.getAttribute("shoppingCar") != null) {//拿session最精準,list會變
            ShoppingCar shoppingcar = (ShoppingCar) session.getAttribute("shoppingCar");//呼叫購物車物件
            ShoppingCarService shoppingCarService = (ShoppingCarService) getServletContext().getAttribute("shoppingCarService");//
            request.setAttribute("CarSize", shoppingCarService.CountTotal(shoppingcar.getShoppingCarMap()));//數量給頁面
        } else {
//         Map<Book,Integer> shoppingCarMap=new TreeMap<>();//若無session則set
            session.setAttribute("shoppingCar", new ShoppingCar());//若無session則建立
        }


//         BookService bookService=(BookService) getServletContext().getAttribute("bookService");
//        
//
//        request.setAttribute("bookSet", bookService.getAllBook());//List給頁面
        request.getRequestDispatcher("BookStore.jsp").forward(request, response);
    }