質問編集履歴
2
ご迷惑おかけいたしまして、申し訳ございません。1、index.jspが表示されません2、コンソールにエラーは出ておりません3、ディレクトリの構造を記載させていただきました。4、コードの編集を行いました
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,12 +28,12 @@
|
|
28
28
|
|
29
29
|
### 該当のソースコード
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
```ここに言語名を入力
|
34
|
-
|
35
31
|
index.jsp
|
36
32
|
|
33
|
+
```jsp
|
34
|
+
|
35
|
+
|
36
|
+
|
37
37
|
|
38
38
|
|
39
39
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
@@ -70,12 +70,16 @@
|
|
70
70
|
|
71
71
|
</html>
|
72
72
|
|
73
|
+
```
|
74
|
+
|
73
75
|
|
74
76
|
|
75
77
|
loginResult.jsp
|
76
78
|
|
77
79
|
|
78
80
|
|
81
|
+
```jsp
|
82
|
+
|
79
83
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
80
84
|
|
81
85
|
pageEncoding="UTF-8"%>
|
@@ -124,11 +128,13 @@
|
|
124
128
|
|
125
129
|
</html>
|
126
130
|
|
131
|
+
```
|
132
|
+
|
127
133
|
|
128
134
|
|
129
135
|
Login.java
|
130
136
|
|
131
|
-
|
137
|
+
```java
|
132
138
|
|
133
139
|
package servlet;
|
134
140
|
|
@@ -236,7 +242,7 @@
|
|
236
242
|
|
237
243
|
}
|
238
244
|
|
239
|
-
|
245
|
+
```
|
240
246
|
|
241
247
|
|
242
248
|
|
@@ -244,6 +250,8 @@
|
|
244
250
|
|
245
251
|
|
246
252
|
|
253
|
+
```java
|
254
|
+
|
247
255
|
package model;
|
248
256
|
|
249
257
|
|
@@ -262,13 +270,13 @@
|
|
262
270
|
|
263
271
|
}
|
264
272
|
|
265
|
-
|
273
|
+
```
|
266
274
|
|
267
275
|
|
268
276
|
|
269
277
|
Mutter.java
|
270
278
|
|
271
|
-
|
279
|
+
```java
|
272
280
|
|
273
281
|
package model;
|
274
282
|
|
@@ -302,9 +310,11 @@
|
|
302
310
|
|
303
311
|
|
304
312
|
|
313
|
+
```
|
314
|
+
|
305
315
|
User.java
|
306
316
|
|
307
|
-
|
317
|
+
```java
|
308
318
|
|
309
319
|
package model;
|
310
320
|
|
@@ -355,3 +365,33 @@
|
|
355
365
|
|
356
366
|
|
357
367
|
### 補足情報(FW/ツールのバージョンなど)
|
368
|
+
|
369
|
+
ディレクトリです
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
yakuin
|
374
|
+
|
375
|
+
>javaリソース
|
376
|
+
|
377
|
+
>src
|
378
|
+
|
379
|
+
>model
|
380
|
+
|
381
|
+
・LoginLogic.java
|
382
|
+
|
383
|
+
・Mutter.java
|
384
|
+
|
385
|
+
・User.java
|
386
|
+
|
387
|
+
>servlet
|
388
|
+
|
389
|
+
・Login.java
|
390
|
+
|
391
|
+
>WebContent
|
392
|
+
|
393
|
+
>WEB-INF
|
394
|
+
|
395
|
+
・index.jsp
|
396
|
+
|
397
|
+
・loginResult
|
1
コードを記載しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,315 @@
|
|
32
32
|
|
33
33
|
```ここに言語名を入力
|
34
34
|
|
35
|
+
index.jsp
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
40
|
+
|
41
|
+
pageEncoding="UTF-8"%>
|
42
|
+
|
43
|
+
<!DOCTYPE html>
|
44
|
+
|
45
|
+
<html>
|
46
|
+
|
47
|
+
<head>
|
48
|
+
|
49
|
+
<meta charset="UTF-8">
|
50
|
+
|
51
|
+
<title>役員報告</title>
|
52
|
+
|
53
|
+
</head>
|
54
|
+
|
55
|
+
<body>
|
56
|
+
|
57
|
+
<h1>役員報告</h1>
|
58
|
+
|
59
|
+
<form action="/yakuin/Login" method="post">
|
60
|
+
|
61
|
+
ユーザー名:<input type="text" name="name"><br>
|
62
|
+
|
63
|
+
パスワード:<input type="password" name="pass"><br>
|
64
|
+
|
65
|
+
<input type="submit" value="ログイン">
|
66
|
+
|
67
|
+
</form>
|
68
|
+
|
69
|
+
</body>
|
70
|
+
|
71
|
+
</html>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
loginResult.jsp
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
80
|
+
|
81
|
+
pageEncoding="UTF-8"%>
|
82
|
+
|
83
|
+
<%@ page import="model.User" %>
|
84
|
+
|
35
|
-
|
85
|
+
<%
|
86
|
+
|
87
|
+
User loginUser = (User)session.getAttribute("loginUser");
|
88
|
+
|
89
|
+
%>
|
90
|
+
|
91
|
+
<!DOCTYPE html>
|
92
|
+
|
93
|
+
<html>
|
94
|
+
|
95
|
+
<head>
|
96
|
+
|
97
|
+
<meta charset="UTF-8">
|
98
|
+
|
99
|
+
<title>役員報告</title>
|
100
|
+
|
101
|
+
</head>
|
102
|
+
|
103
|
+
<body>
|
104
|
+
|
105
|
+
<h1>役員ログイン</h1>
|
106
|
+
|
107
|
+
<% if(loginUser !=null){ %>
|
108
|
+
|
109
|
+
<p>ログインに成功しました!</p>
|
110
|
+
|
111
|
+
<p>おはようございます<%= loginUser.getName() %>さん</p>
|
112
|
+
|
113
|
+
<a href="/yakuin/Main">役員報告一覧</a>
|
114
|
+
|
115
|
+
<%}else{ %>
|
116
|
+
|
117
|
+
<p>ログインに失敗しました</p>
|
118
|
+
|
119
|
+
<a href="/yakuin/">TOPへ</a>
|
120
|
+
|
121
|
+
<% } %>
|
122
|
+
|
123
|
+
</body>
|
124
|
+
|
125
|
+
</html>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
Login.java
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
package servlet;
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
import java.io.IOException;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
import javax.servlet.RequestDispatcher;
|
142
|
+
|
143
|
+
import javax.servlet.ServletException;
|
144
|
+
|
145
|
+
import javax.servlet.annotation.WebServlet;
|
146
|
+
|
147
|
+
import javax.servlet.http.HttpServlet;
|
148
|
+
|
149
|
+
import javax.servlet.http.HttpServletRequest;
|
150
|
+
|
151
|
+
import javax.servlet.http.HttpServletResponse;
|
152
|
+
|
153
|
+
import javax.servlet.http.HttpSession;
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
import model.LoginLogic;
|
158
|
+
|
159
|
+
import model.User;
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
/**
|
164
|
+
|
165
|
+
* Servlet implementation class Login
|
166
|
+
|
167
|
+
*/
|
168
|
+
|
169
|
+
@WebServlet("/Login")
|
170
|
+
|
171
|
+
public class Login extends HttpServlet {
|
172
|
+
|
173
|
+
private static final long serialVersionUID = 1L;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
/**
|
178
|
+
|
179
|
+
* @see HttpServlet#HttpServlet()
|
180
|
+
|
181
|
+
*/
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
// TODO Auto-generated constructor stub
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
/**
|
192
|
+
|
193
|
+
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
194
|
+
|
195
|
+
*/
|
196
|
+
|
197
|
+
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
198
|
+
|
199
|
+
// TODO Auto-generated method stub
|
200
|
+
|
201
|
+
request.setCharacterEncoding("UTF-8");
|
202
|
+
|
203
|
+
String name= request.getParameter("name");
|
204
|
+
|
205
|
+
String pass = request.getParameter("pass");
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
User user =new User(name,pass);
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
LoginLogic loginLogic=new LoginLogic();
|
214
|
+
|
215
|
+
boolean isLogin =loginLogic.execute(user);
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
if(isLogin) {
|
220
|
+
|
221
|
+
HttpSession session = request.getSession();
|
222
|
+
|
223
|
+
session.setAttribute("loginUser", user);
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
RequestDispatcher dispatcher=
|
230
|
+
|
231
|
+
request.getRequestDispatcher("/WEB-INF/jsp/loginResult.jsp");
|
232
|
+
|
233
|
+
dispatcher.forward(request,response);
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
LoginLogic.java
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
package model;
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
public class LoginLogic {
|
252
|
+
|
253
|
+
public boolean execute(User user) {
|
254
|
+
|
255
|
+
if(user.getPass().contentEquals("1234")) {return true;}
|
256
|
+
|
257
|
+
return false;
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
Mutter.java
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
package model;
|
274
|
+
|
275
|
+
import java.io.Serializable;
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
public class Mutter implements Serializable{
|
280
|
+
|
281
|
+
private String userName;
|
282
|
+
|
283
|
+
private String text;
|
284
|
+
|
285
|
+
public Mutter() {}
|
286
|
+
|
287
|
+
public Mutter(String userName,String text) {
|
288
|
+
|
289
|
+
this.userName=userName;
|
290
|
+
|
291
|
+
this.text=text;
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
public String getUserName() {return userName;}
|
296
|
+
|
297
|
+
public String getText() {return text;}
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
User.java
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
package model;
|
310
|
+
|
311
|
+
import java.io.Serializable;
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
public class User implements Serializable{
|
316
|
+
|
317
|
+
private String name;
|
318
|
+
|
319
|
+
private String pass;
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
public User() {}
|
324
|
+
|
325
|
+
public User(String name,String pass) {
|
326
|
+
|
327
|
+
this.name=name;
|
328
|
+
|
329
|
+
this.pass=pass;
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
public String getName() {return name;}
|
334
|
+
|
335
|
+
public String getPass() {return pass;}
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
36
344
|
|
37
345
|
```
|
38
346
|
|
@@ -47,7 +355,3 @@
|
|
47
355
|
|
48
356
|
|
49
357
|
### 補足情報(FW/ツールのバージョンなど)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
ここにより詳細な情報を記載してください。![![![![![![![イメージ説明](a1a51d320c1e3a01e67ae504ebc18771.png)](0648a53f9f30ad3ae44db3510346361d.png)](d327c6c16378c1468297fc337c327bfe.png)](e86b8157b1748b8547fa40c83950f5f4.png)](bc627988f77c54f47fb145a026c656ed.png)](18586fa31352c735bd4f795dd0a6d6c7.png)](a6e97c12b71912450f2b6fc3125bdedb.png)
|