<AccController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.smhrd.dao.UseDAO;
import com.smhrd.domain.AccVO;
import com.smhrd.domain.HelmetVO;
import com.smhrd.domain.UseVO;
import com.smhrd.module.module;
public class AccController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
System.out.println("acc.do로 가기 성공");
String hel_number = module.hel_number_shock;
System.out.println(hel_number);
int shock = module.shock;
String moveURL = "";
if(shock == 1) {
UseDAO dao = new UseDAO();
AccVO vo = dao.accView(hel_number);
UseVO usevo = dao.useList2(hel_number);
System.out.println(usevo.getUse_number());
HelmetVO helmetvo = dao.startGPS(hel_number);
int use_number = usevo.getUse_number();
System.out.println();
String acc_loc_lat = helmetvo.getHel_loc_lat();
String acc_loc_long = helmetvo.getHel_loc_long();
AccVO accvo = new AccVO(use_number, acc_loc_lat, acc_loc_long);
dao.accList(accvo);
AccVO accList = dao.accListView(use_number);
System.out.println("사고 장소 위도 : " + accList.getAcc_loc_lat());
System.out.println("사고 장소 경도 : " + accList.getAcc_loc_long());
if (vo != null) {
System.out.println("success");
session.setAttribute("acc_vo", vo);
session.setAttribute("acc_helmet", accList);
moveURL = "sos";
} else {
System.out.println("false");
}
}
return moveURL;
}
}
<Controller>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface Controller {
public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;
}
<FAQController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class FAQController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "faq";
}
}
<HlocationController>
package com.smhrd.controller;
import java.io.IOException;
import java.io.PrintWriter;
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.google.gson.Gson;
import com.smhrd.dao.MemberDAO;
import com.smhrd.domain.HelmetVO;
import com.smhrd.domain.UlocationVO;
@WebServlet("/Hlocation.do")
public class HlocationController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/json;charset=utf-8");
String hel_number = request.getParameter("hel_number");
System.out.println("ajax통신 성공");
System.out.println(hel_number);
MemberDAO dao = new MemberDAO();
HelmetVO vo = new HelmetVO();
vo =dao.whereHelmet(hel_number);
Gson g = new Gson();
String json = g.toJson(vo);
System.out.println("json성공!");
// 값받아짐 확인
System.out.println(vo.getHel_loc_lat());
response.setContentType("text/json;charset=utf-8");
PrintWriter out =response.getWriter();
out.println(json);
}
}
<JoinController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.smhrd.dao.DAO;
import com.smhrd.domain.Member;
public class JoinController implements Controller{
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String mem_id = request.getParameter("mem_id");
String mem_pw = request.getParameter("mem_pw");
String mem_name = request.getParameter("mem_name");
String mem_gender = request.getParameter("mem_gender");
String mem_blood = request.getParameter("mem_blood");
String mem_phone = request.getParameter("mem_phone");
String mem_subphone = request.getParameter("mem_subphone");
String mem_birth = request.getParameter("mem_birth");
String drivenum = request.getParameter("drivenum");
Member vo = new Member(0, mem_id, mem_pw, mem_name, mem_gender, mem_blood, mem_phone, mem_subphone, mem_birth, drivenum);
DAO dao = new DAO();
int row = dao.Join(vo);
request.setAttribute("mem_id", mem_id);
return "join_success";
}
}
<LoginController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.smhrd.dao.DAO;
import com.smhrd.domain.Member;
public class LoginController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String mem_id = request.getParameter("mem_id");
String mem_pw = request.getParameter("mem_pw");
System.out.println(mem_id);
System.out.println(mem_pw);
Member vo = new Member(0, mem_id, mem_pw, null, null, null, null, null, null, null);
DAO dao= new DAO();
Member result = dao.login(vo);
String moveURL = "";
if(result != null) {
HttpSession session = request.getSession();
session.setAttribute("member", result);
session.setAttribute("mem_id", mem_id);
moveURL = "main";
}else {
moveURL = "login";
}
return moveURL;
}
<LogoutController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.smhrd.dao.DAO;
import com.smhrd.domain.Member;
import com.smhrd.module.moduleController;
public class LogoutController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
session.invalidate();
moduleController.motor = 0;
return "main";
}
}
<MemberlistController>
package com.smhrd.controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.smhrd.dao.MemberDAO;
import com.smhrd.domain.Member;
public class MemberlistController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
MemberDAO dao = new MemberDAO();
ArrayList<Member> list = dao.getAllList();
request.setAttribute("list", list);
return "memberList";
}
}
<stopController>
package com.smhrd.controller;
import java.io.IOException;
import java.io.PrintWriter;
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.google.gson.Gson;
import com.smhrd.dao.UseDAO;
import com.smhrd.domain.HelmetVO;
import com.smhrd.domain.UseVO;
@WebServlet("/stop.do")
public class stopController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/json;charset=utf-8");
String mem_id = request.getParameter("mem_id");
UseDAO dao = new UseDAO();
UseVO result = dao.useList(mem_id);
String hel_number = result.getHel_number();
HelmetVO helVO = dao.startGPS(hel_number);
int use_number = result.getUse_number();
String end_loc_lat = helVO.getHel_loc_lat();
String end_loc_long = helVO.getHel_loc_long();
UseVO vo = new UseVO(use_number, end_loc_lat, end_loc_long);
dao.stopGPS(vo);
int row = dao.stop(mem_id);
System.out.println("stopController json성공!");
PrintWriter out =response.getWriter();
response.setContentType("text/json;charset=utf-8");
out.println(row);
}
}
<UlocationController>
package com.smhrd.controller;
import java.io.IOException;
import java.io.PrintWriter;
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.google.gson.Gson;
import com.smhrd.dao.MemberDAO;
import com.smhrd.domain.UlocationVO;
@WebServlet("/Ulocation.do")
public class UlocationController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/json;charset=utf-8");
String mem_id = request.getParameter("mem_id");
System.out.println("ajax통신 성공");
System.out.println(mem_id);
MemberDAO dao = new MemberDAO();
UlocationVO vo = dao.Ulocation(mem_id);
Gson g = new Gson();
String json = g.toJson(vo);
System.out.println("json성공!");
// 값받아짐 확인
System.out.println(vo.getHel_loc_lat());
response.setContentType("text/json;charset=utf-8");
PrintWriter out =response.getWriter();
out.println(json);
}
}
<UseController>
package com.smhrd.controller;
import java.io.IOException;
import java.io.PrintWriter;
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 org.apache.catalina.Session;
import com.google.gson.Gson;
import com.smhrd.dao.MemberDAO;
import com.smhrd.dao.UseDAO;
import com.smhrd.domain.HelmetVO;
import com.smhrd.domain.UlocationVO;
import com.smhrd.domain.UseVO;
import com.smhrd.module.module;
@WebServlet("/use.do")
public class UseController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/json;charset=utf-8");
HttpSession session = request.getSession();
String hel_number = request.getParameter("hel_num");
String kick_number = request.getParameter("kick_num");
String mem_id = (String)session.getAttribute("mem_id");
UseDAO dao = new UseDAO();
HelmetVO helVO = dao.startGPS(hel_number);
String start_loc_lat = helVO.getHel_loc_lat();
String start_loc_long = helVO.getHel_loc_long();
UseVO vo = new UseVO(kick_number, hel_number, mem_id, start_loc_lat, start_loc_long);
dao.useInsert(vo);
UseVO result = dao.useList(mem_id);
Gson g = new Gson();
String json = g.toJson(result);
PrintWriter out =response.getWriter();
response.setContentType("text/json;charset=utf-8");
out.println(json);
}
}
<UsingController>
package com.smhrd.controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.smhrd.dao.UseDAO;
import com.smhrd.domain.UseVO;
public class UsinglistController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
// HttpSession session = request.getSession();
// String mem_id = (String) session.getAttribute("mem_id");
String mem_id = request.getParameter("mem_id");
System.out.println(mem_id);
UseDAO dao = new UseDAO();
ArrayList<UseVO> list= dao.usinglist(mem_id);
request.setAttribute("list", list);
return "usingList";
}
}
<ViewBlackboxController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewBlackboxController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "blackbox";
}
}
<ViewHlocationController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewHlocationController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "hLocation";
}
}
<ViewJoinController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewJoinController implements Controller{
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "join";
}
}
<ViewLoginController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewLoginController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "login";
}
}
<ViewMainController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewMainController implements Controller{
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "main";
}
}
<ViewUlocationController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewUlocationController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "uLocation";
}
}
<ViewUseController>
package com.smhrd.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ViewUlocationController implements Controller {
@Override
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
return "uLocation";
}
}
'2차 프로젝트' 카테고리의 다른 글
아두이노 Module 코드 (0) | 2022.07.22 |
---|---|
FrontController 코드 (0) | 2022.07.22 |
Domain 코드 (0) | 2022.07.22 |
DAO 코드 (0) | 2022.07.22 |
프로젝트 산출문서 (0) | 2022.07.22 |