|
@@ -0,0 +1,53 @@
|
|
|
+package com.it.servlet;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import javax.servlet.ServletException;
|
|
|
+import javax.servlet.http.HttpServlet;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.it.service.CourseService;
|
|
|
+import com.it.service.DisciplineService;
|
|
|
+import com.it.service.impl.CourseServiceImpl;
|
|
|
+import com.it.service.impl.DisciplineServiceImpl;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Servlet implementation class DeleteServlet
|
|
|
+ */
|
|
|
+public class DeleteServlet extends HttpServlet {
|
|
|
+
|
|
|
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
+
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+
|
|
|
+ try {
|
|
|
+ String name = request.getParameter("name");
|
|
|
+ String level = name.substring(name.length()-2, name.length());
|
|
|
+ name = name.substring(0, name.length() - 2);
|
|
|
+
|
|
|
+ if(level.equals("ds"))
|
|
|
+ {
|
|
|
+ DisciplineService disciplineService = new DisciplineServiceImpl();
|
|
|
+ disciplineService.delete(name);
|
|
|
+ CourseService courseService = new CourseServiceImpl();
|
|
|
+ courseService.deleteByDiscipline(name);
|
|
|
+ }else if(level.equals("cs")){
|
|
|
+ CourseService courseService = new CourseServiceImpl();
|
|
|
+ courseService.delete(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ request.getRequestDispatcher("DisciplineListServlet").forward(request, response);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
|
|
+ */
|
|
|
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ doGet(request, response);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|