@WebServlet("*.us")
public class UserFrontController extends HttpServlet{
// doGet, doPost에서 공통의 process 메서드 호출
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
// 공통 로직 처리 메서드
protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String requestURI = request.getRequestURI();
ActionForward forward = null;
// 각각의 컨트롤러 호출
if(requestURI.equals("/user/userJoin.us")) {
forward = new UserJoinAction().execute(request, response);
}else if(requestURI.equals("/user/UserLogin.us")) {
forward = new ActionForward(false,"/app/user/loginview.jsp");
}else if(requestURI.equals("/user/UserLoginOk.us")) {
forward = new UserLoginOkAction().execute(request,response);
}
// 전송에 대한 일괄처리
if(forward != null) {
if(forward.isRedirect()) {
// true : redirect
response.sendRedirect(forward.getPath());
}else {
// false : forward
RequestDispatcher disp
= request.getRequestDispatcher(forward.getPath());
disp.forward(request, response);
}
}
}
}