-
[회원 가입] Controller프로젝트 2022. 7. 21. 12:28
TaxiJoinService
package com.ptsd.controller; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.ptsd.model.TaxiDAO; import com.ptsd.model.TaxiVO; @WebServlet("/TaxiJoinService") public class TaxiJoinService extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1. 한글 인코딩 request.setCharacterEncoding("UTF-8"); //2. 데이터 가져오기 String Taxi_num = request.getParameter("Taxi_num"); String Car_kinds = request.getParameter("Car_kinds"); String Office_name = request.getParameter("Office_name"); int Personal_tel =Integer.parseInt(request.getParameter("Personal_tel")); String Approve_check = request.getParameter("Approve_check"); String Pw = request.getParameter("Pw"); //3. 데이터 묶기 TaxiVO vo = new TaxiVO(Taxi_num, Car_kinds, Office_name, Personal_tel, Approve_check,Pw); //4. DB에 데이터 접어넣기 TaxiDAO dao = new TaxiDAO(); int row=dao.taxiinsert(vo); //5.흐름제어 if(row>0) { HttpSession session = request.getSession(); session.setAttribute("taxi", Taxi_num); System.out.println("가입완"); //jsp 변경 RequestDispatcher rd = request.getRequestDispatcher("index.jsp"); rd.forward( request, response); }else { //메인 변경 response.sendRedirect("index.jsp"); } } }
TaxiUpdateService
package com.ptsd.controller; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.ptsd.model.TaxiDAO; import com.ptsd.model.TaxiVO; @WebServlet("/TaxiUpdateService") public class TaxiUpdateSerivce extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); HttpSession session = request.getSession(); String Taxi_num = ((TaxiVO) session.getAttribute("member")).getTaxi_num(); // 로그인한 사용자의 taxi_num을 가져오는 방법 String Car_kinds = request.getParameter("Car_kinds"); String Office_name = request.getParameter("Office_name"); int Personal_tel = Integer.parseInt(request.getParameter("Personal_tel")); String Approve_check = request.getParameter("Approve_check"); String Pw = request.getParameter("Pw"); TaxiVO vo = new TaxiVO(Taxi_num, Car_kinds, Office_name, Personal_tel, Approve_check, Pw); TaxiDAO dao = new TaxiDAO(); int row = dao.taxiupdate(vo); System.out.println(vo); System.out.println(row); if (row > 0) { System.out.println("수정ㅇ완"); session.setAttribute("taxi", vo); System.out.println(session); } // 메인.jsp변경 RequestDispatcher rd = request.getRequestDispatcher("index.jsp"); rd.forward(request, response); } }
TaxiDeleteService
package com.ptsd.controller; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.ptsd.model.TaxiDAO; import com.ptsd.model.TaxiVO; @WebServlet("/TaxiDeleteService") public class TaxiDeleteService extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String Taxi_num = ((TaxiVO) session.getAttribute("member")).getTaxi_num(); TaxiDAO dao=new TaxiDAO(); int row=dao.taxidelete(Taxi_num); if(row>0) { System.out.println("삭제완."); } //jsp변경 RequestDispatcher rd=request.getRequestDispatcher("main.jsp"); rd.forward(request, response); } }
'프로젝트' 카테고리의 다른 글
[회원 가입, 로그인] Model (0) 2022.07.21 [회원 가입, 로그인] DataBase (0) 2022.07.21 [라즈베리파이] 인체감지센서(HC-SR501) Display ON/OFF (0) 2022.07.14 프로젝트 발표용 ppt (0) 2022.07.14 프로젝트 산출문서 (0) 2022.07.14