1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package 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;
@WebServlet(name = "/FrontController" , urlPatterns = "*.do")
public class FrontController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
// 넘어온 url 값 뽑기
String uri = request.getRequestURI();
System.out.println(uri);
// 넘어온 project 뽑기
String pj = request.getContextPath();
System.out.println(pj);
// url 을 project 만큼 잘라내기
String command = uri.substring(pj.length());
System.out.println(command);
//ex) /member/memberList.do
// /memberList.do 짤라내기
String[] subpath = command.split("/");
String location = subpath[1];
System.out.println(location);
if(location.equals("member")) {
MemberController mc = new MemberController();
mc.process(request, response);
}else if(location.equals("board")) {
BoardController bc = new BoardController();
bc.process(request,response);
}else if(location.equals("item")) {
itemController ic = new itemController();
ic.process(request,response);
}else if(location.equals("res")) {
ResController rs = new ResController();
rs.process(request,response);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
|
cs |
'기존 > 🏀Jsp' 카테고리의 다른 글
[JSP] jsp 비밀번호 찾기 로직 구현하기 (0) | 2022.05.31 |
---|---|
[JSP] jsp 회원 아이디 찾기 로직 구현하기 (0) | 2022.05.31 |
[JSP] 회원로그인 로직 구현하기 (0) | 2022.05.31 |
[JSP] jsp 회원가입 로직 구현하기 (0) | 2022.05.31 |
Http post 형식으로 보내기 이클립스 (0) | 2022.05.29 |