public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = request.getParameter("id"); BusinessService service = new BusinessServiceImpl(); Book book = service.findBook(id); Cart cart = (Cart) request.getSession().getAttribute("cart"); if (cart == null) { cart = new Cart(); request.getSession().setAttribute("cart", cart); } cart.add(book); response.sendRedirect(request.getContextPath() + "/client/listcart.jsp"); }
private void getAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List list = service.getAllCategory(); request.setAttribute("categories", list); request.getRequestDispatcher("/manager/listcategory.jsp").forward(request, response); }
private void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Category c = WebUtils.request2Bean(request, Category.class); c.setId(UUID.randomUUID().toString()); service.addCategory(c); request.setAttribute("message", "Ìí¼Ó³É¹¦"); } catch (Exception e) { e.printStackTrace(); request.setAttribute("message", "Ìí¼Óʧ°Ü"); } request.getRequestDispatcher("/message.jsp").forward(request, response); }