dogetImportSourceController

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.4 kB
1
Indexable
Never
if (path.endsWith("/Admin/ImportSource")) {
            request.getRequestDispatcher("/adminImportSource.jsp").forward(request, response);
        } else {
            if (path.endsWith("/Admin/ImportSource")) {
                request.getRequestDispatcher("/adminImportSource.jsp").forward(request, response);
            } else {
                if (path.endsWith("/Admin/AddNewImportSource")) {
                    request.getRequestDispatcher("/addNewImportSource.jsp").forward(request, response);
                } else if (path.startsWith("/Admin/UpdateImportSource")) {
                    try {
                        String[] data = path.split("/");
                        int id = Integer.parseInt(data[data.length - 1]);
                        AdminDAOs dao = new AdminDAOs();
                        ImportSource ip = dao.GetImportSource(id);
                        if (ip == null) {
                            response.sendRedirect("/Admin/ImportSource");
                        } else {
                            HttpSession session = request.getSession();
                            session.setAttribute("importSourceInformation", ip);
                            request.getRequestDispatcher("/updateImportSource.jsp").forward(request, response);
                        }
                    } catch (SQLException | ClassNotFoundException ex) {
                        Logger.getLogger(AdminController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    if (path.startsWith("/Admin/DeleteImportSource/")) {
                        try {
                            String[] data = path.split("/");
                            int id = Integer.parseInt(data[data.length - 1]);
                            AdminDAOs dao = new AdminDAOs();
                            dao.DeleteImportSource(id);
                            response.sendRedirect("/Admin/ImportSource");
                        } catch (SQLException ex) {
                            Logger.getLogger(AdminController.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (ClassNotFoundException ex) {
                            Logger.getLogger(AdminController.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
            }
        }