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


        String action = request.getParameter(ACTION);
        List<MenuItem> updatedItems = null;


        MenuService ms = new MenuService();

        if (action.equals("Delete")) {

            try {

                ms.deleteMenuItem(request.getParameterValues("item"));
                updatedItems = ms.getAllMenuItems();

            } catch (DataAccessException ex) {
            }

            request.setAttribute("menuitems", updatedItems);


            RequestDispatcher view =
                    request.getRequestDispatcher(DESTINATION_URL);
            view.forward(request, response);
        } else if (action.equals("Add/Change")) {

            String[] ids = request.getParameterValues("item");

            if (ids == null) {
                MenuItem item = new MenuItem();
                request.setAttribute("item", item);
            } else {
                try {

                    MenuItem item = ms.getMenuItem(ids[0]);
                    request.setAttribute("item", item);
                } catch (DataAccessException ex) {

                    Logger.getLogger(AdminUpdateController.class.getName()).log(Level.SEVERE, null, ex);

                }

            }

            RequestDispatcher view =
                    request.getRequestDispatcher("/adminUpdateForm.jsp");
            view.forward(request, response);

        } else if (action.equals("Finalize")) {

            String id = request.getParameter("id");
            Long objId = (id == null || id.length() == 0) ? null : new Long(id);
            String name = request.getParameter("itemName");
            double price = Double.valueOf(request.getParameter("itemPrice"));

            MenuItem mi = new MenuItem(name, price, objId);
            try {

                ms.updateMenuItem(mi);
                updatedItems = ms.getAllMenuItems();

            } catch (DataAccessException ex) {
                Logger.getLogger(AdminUpdateController.class.getName()).log(Level.SEVERE, null, ex);
            }

            request.setAttribute("menuitems", updatedItems);

            RequestDispatcher view =
                    request.getRequestDispatcher(DESTINATION_URL);
            view.forward(request, response);
        }

    }