@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String orderItem = request.getParameter("orderItem"); System.out.println("submit button :" + orderItem); if (null == orderItem) { Map<String, String> queryParameters = new HashMap<String, String>(); String itemName = request.getParameter("itemName"); String catId = request.getParameter("categoryList"); String supId = request.getParameter("suppliersList"); System.out.println("servlets.CreateOrderServlet.doPost()"); queryParameters.put("itemName", itemName); queryParameters.put("catId", catId); List<Item> items = itemManagementBean.searchItem(queryParameters); List<Category> categories = categoryManagementBean.findAll(); List<Supplier> suppliers = supplierManagementBean.findAllSuppliers(); request.setAttribute("categories", categories); request.setAttribute("suppliers", suppliers); request.setAttribute("items", items); RequestDispatcher rd = request.getRequestDispatcher("create_order.jsp"); rd.include(request, response); } else { Item item = itemManagementBean.getItemById(orderItem); request.setAttribute("orderItem", item); RequestDispatcher rd = request.getRequestDispatcher("consume_item.jsp"); rd.include(request, response); } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<Category> categories = categoryManagementBean.findAll(); List<Supplier> suppliers = supplierManagementBean.findAllSuppliers(); List<Item> items = itemManagementBean.findAllItems(); request.setAttribute("categories", categories); request.setAttribute("suppliers", suppliers); request.setAttribute("items", items); RequestDispatcher rd = request.getRequestDispatcher("create_order.jsp"); rd.include(request, response); }