質問編集履歴
3
文字追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,61 @@
|
|
28
28
|
|
29
29
|
```Servletコード
|
30
30
|
|
31
|
-
|
31
|
+
/**
|
32
|
+
|
33
|
+
* Servlet implementation class LoginServlet_
|
34
|
+
|
35
|
+
*/
|
36
|
+
|
37
|
+
@WebServlet("/manager-login-servlet")
|
38
|
+
|
39
|
+
public class ManagerLoginServlet extends HttpServlet {
|
40
|
+
|
41
|
+
private static final long serialVersionUID = 1L;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
/**
|
46
|
+
|
47
|
+
* @see HttpServlet#HttpServlet()
|
48
|
+
|
49
|
+
*/
|
50
|
+
|
51
|
+
public ManagerLoginServlet() {
|
52
|
+
|
53
|
+
super();
|
54
|
+
|
55
|
+
// TODO Auto-generated constructor stub
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
/**
|
62
|
+
|
63
|
+
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
64
|
+
|
65
|
+
*/
|
66
|
+
|
67
|
+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
68
|
+
|
69
|
+
// TODO Auto-generated method stub
|
70
|
+
|
71
|
+
response.getWriter().append("Served at: ").append(request.getContextPath());
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
/**
|
78
|
+
|
79
|
+
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
80
|
+
|
81
|
+
*/
|
82
|
+
|
83
|
+
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
84
|
+
|
85
|
+
// TODO Auto-generated method stub
|
32
86
|
|
33
87
|
//DAO作成
|
34
88
|
|
2
文字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -102,6 +102,10 @@
|
|
102
102
|
|
103
103
|
```
|
104
104
|
|
105
|
+
elseとcatchの遷移先はとりあえずloginJSPにしています。
|
106
|
+
|
107
|
+
|
108
|
+
|
105
109
|
JSPのコード
|
106
110
|
|
107
111
|
```
|
1
文字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,15 +24,143 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
|
27
|
+
Servletのコード
|
28
|
+
|
29
|
+
```Servletコード
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
//DAO作成
|
34
|
+
|
35
|
+
UserDao dao = new UserDao();
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
//ID password取得
|
40
|
+
|
41
|
+
String manager_id = request.getParameter("manager_id");
|
42
|
+
|
43
|
+
String manager_password = request.getParameter("manager_password");
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
//リスト作成
|
48
|
+
|
49
|
+
List<ManagerUserBean> m_user = new ArrayList<>();
|
27
50
|
|
28
51
|
|
29
52
|
|
30
53
|
|
31
54
|
|
55
|
+
//セッション作成
|
32
56
|
|
33
|
-
|
57
|
+
HttpSession session = request.getSession();
|
34
58
|
|
35
59
|
|
60
|
+
|
61
|
+
//遷移先初期化
|
62
|
+
|
63
|
+
String url;
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
try {
|
68
|
+
|
69
|
+
if(dao.Managerlogin(manager_id, manager_password)) {
|
70
|
+
|
71
|
+
session.setAttribute("maneger_id", manager_id);
|
72
|
+
|
73
|
+
m_user = dao.selectAll1();
|
74
|
+
|
75
|
+
session.setAttribute("m_user", m_user);
|
76
|
+
|
77
|
+
url = "menu.jsp";
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
else {
|
82
|
+
|
83
|
+
url = "manager-login.jsp";
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
} catch (ClassNotFoundException | SQLException e) {
|
88
|
+
|
89
|
+
url = "manager-login.jsp";
|
90
|
+
|
91
|
+
e.printStackTrace();
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
RequestDispatcher rd = request.getRequestDispatcher(url);
|
98
|
+
|
99
|
+
rd.forward(request, response);
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
JSPのコード
|
106
|
+
|
107
|
+
```
|
108
|
+
|
109
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
110
|
+
|
111
|
+
pageEncoding="UTF-8"%>
|
112
|
+
|
113
|
+
<!DOCTYPE html>
|
114
|
+
|
115
|
+
<html>
|
116
|
+
|
117
|
+
<head>
|
118
|
+
|
119
|
+
<meta charset="UTF-8">
|
120
|
+
|
121
|
+
<title>ログイン画面</title>
|
122
|
+
|
123
|
+
<link rel="stylesheet" href="CSS/style.css">
|
124
|
+
|
125
|
+
</head>
|
126
|
+
|
127
|
+
<body>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<%-- 入力フォーム --%>
|
134
|
+
|
135
|
+
<form action="manager-login-servlet" method="post">
|
136
|
+
|
137
|
+
<dl class="login-form">
|
138
|
+
|
139
|
+
<dt>ユーザID:</dt>
|
140
|
+
|
141
|
+
<dd><input type="text" size=10 name="manager_id"></dd>
|
142
|
+
|
143
|
+
<dt>パスワード:</dt>
|
144
|
+
|
145
|
+
<dd><input type="password" size=10 name="manager_password"></dd>
|
146
|
+
|
147
|
+
</dl>
|
148
|
+
|
149
|
+
<input type="submit" value="送信"><br>
|
150
|
+
|
151
|
+
</form>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<br>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
</body>
|
160
|
+
|
161
|
+
</html>
|
162
|
+
|
163
|
+
```
|
36
164
|
|
37
165
|
マッピングなどは正しいです。
|
38
166
|
|