public void init() throws ServletException { connection = SQLOperations.getConnection(); if (connection != null) { System.out.println("CONNECTED"); } else { System.out.println("NULL CONNECTION"); } }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String product_code = request.getParameter("product_code"); System.out.println(request.getParameter("product_code")); String directory; if (request.getParameter("action").equals("edit")) { directory = "/editProduct.jsp"; ProductBean productBean = SQLOperations.findProduct(product_code, connection); request.setAttribute("productBean", productBean); } else if (request.getParameter("action").equals("delete")) { directory = "/deleteProduct.jsp"; ProductBean productBean = SQLOperations.findProduct(product_code, connection); request.setAttribute("productBean", productBean); } else if (request.getParameter("action").equals("sell")) { directory = "/sellProductDetails.jsp"; ProductBean productBean = SQLOperations.findProduct(product_code, connection); request.setAttribute("productBean", productBean); } else { directory = "/MainMenu.jsp"; } getServletContext().getRequestDispatcher(directory).forward(request, response); }