質問編集履歴
5
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,6 +32,20 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
35
49
|
!!!!!!----LoginLogicTestです。
|
36
50
|
|
37
51
|
|
@@ -112,6 +126,10 @@
|
|
112
126
|
|
113
127
|
|
114
128
|
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
115
133
|
!!!!!-----Login.javaです。
|
116
134
|
|
117
135
|
package model;
|
@@ -158,6 +176,22 @@
|
|
158
176
|
|
159
177
|
|
160
178
|
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
161
195
|
!!!!!-----AccountDAOです。
|
162
196
|
|
163
197
|
|
@@ -384,124 +418,58 @@
|
|
384
418
|
|
385
419
|
|
386
420
|
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
387
|
-
!!!!!-----Login
|
435
|
+
!!!!!-----LoginLogic.javaです。
|
388
|
-
|
436
|
+
|
437
|
+
|
438
|
+
|
389
|
-
|
439
|
+
package model;
|
390
|
-
|
391
|
-
|
392
|
-
|
440
|
+
|
441
|
+
|
442
|
+
|
393
|
-
import
|
443
|
+
import dao.AccountDAO;
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
444
|
+
|
398
|
-
|
399
|
-
|
445
|
+
|
400
|
-
|
401
|
-
|
446
|
+
|
402
|
-
|
403
|
-
import javax.servlet.http.HttpServlet;
|
404
|
-
|
405
|
-
import javax.servlet.http.HttpServletRequest;
|
406
|
-
|
407
|
-
import javax.servlet.http.HttpServletResponse;
|
408
|
-
|
409
|
-
import javax.servlet.http.HttpSession;
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
import model.Login;
|
414
|
-
|
415
|
-
i
|
447
|
+
public class LoginLogic{
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
448
|
+
|
420
|
-
|
421
|
-
|
449
|
+
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
450
|
+
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
|
432
|
-
|
433
|
-
|
451
|
+
//executメソッド
|
434
|
-
|
435
|
-
|
452
|
+
|
436
|
-
|
437
|
-
|
453
|
+
public boolean execute(Login login){
|
454
|
+
|
455
|
+
AccountDAO dao=new AccountDAO();
|
456
|
+
|
457
|
+
Account account=dao.findByLogin(login);
|
458
|
+
|
459
|
+
return account !=null;
|
460
|
+
|
461
|
+
|
438
462
|
|
439
463
|
}
|
440
464
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
//taichiのMain.javvaの分のログインしているかのチェックは、ここでおk
|
448
|
-
|
449
|
-
protected void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
//リクエストパラメータの取得
|
454
|
-
|
455
|
-
request.setCharacterEncoding("UTF-8");
|
456
|
-
|
457
|
-
String userId=request.getParameter("userId");
|
458
|
-
|
459
|
-
String pass=request.getParameter("pass");
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
//ログイン処理の実行
|
464
|
-
|
465
|
-
Login login=new Login(userId,pass);
|
466
|
-
|
467
|
-
LoginLogic bo=new LoginLogic();
|
468
|
-
|
469
|
-
boolean result=bo.execute(login);
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
//ログイン処理の成否によって処理を分岐
|
474
|
-
|
475
|
-
if(result){//ログイン成功時
|
476
|
-
|
477
|
-
//sessionスコープにuserIdを保存
|
478
|
-
|
479
|
-
HttpSession session=request.getSession();
|
480
|
-
|
481
|
-
session.setAttribute("userId",userId);
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
//フォワード
|
486
|
-
|
487
|
-
RequestDispatcher dispatcher=request.getRequestDispatcher("/WEB-INF/jsp/loginOK.jsp");
|
488
|
-
|
489
|
-
dispatcher.forward(request, response);
|
490
|
-
|
491
|
-
}else{//ログイン失敗時
|
492
|
-
|
493
|
-
//フォワード
|
494
|
-
|
495
|
-
RequestDispatcher dispatcher=request.getRequestDispatcher("/WEB-INF/jsp/login.jsp");
|
496
|
-
|
497
|
-
dispatcher.forward(request, response);
|
498
|
-
|
499
|
-
}
|
500
|
-
|
501
|
-
}
|
502
|
-
|
503
465
|
}
|
504
466
|
|
505
|
-
!!!!!-----Login
|
467
|
+
!!!!!-----LoginLogic.javaはここまでです。
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
506
474
|
|
507
475
|
どうぞよろしくお願いします。
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
3
わかりやすく変更しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
----LoginLogicTestです。
|
35
|
+
!!!!!!----LoginLogicTestです。
|
36
36
|
|
37
37
|
|
38
38
|
|
@@ -104,15 +104,15 @@
|
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
-
-----LoginLogicTestはここまでです。
|
107
|
+
!!!!!-----LoginLogicTestはここまでです。
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
108
|
-
|
115
|
+
!!!!!-----Login.javaです。
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
116
|
|
117
117
|
package model;
|
118
118
|
|
@@ -154,11 +154,11 @@
|
|
154
154
|
|
155
155
|
}
|
156
156
|
|
157
|
-
|
157
|
+
!!!!!----Login.javaはここまでです。
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
-
-----AccountDAOです。
|
161
|
+
!!!!!-----AccountDAOです。
|
162
162
|
|
163
163
|
|
164
164
|
|
@@ -378,13 +378,13 @@
|
|
378
378
|
|
379
379
|
}
|
380
380
|
|
381
|
-
---AccountDAOはここまでです。
|
381
|
+
!!!!!---AccountDAOはここまでです。
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
-
-----LoginServletです。
|
387
|
+
!!!!!-----LoginServletです。
|
388
388
|
|
389
389
|
package servlet;
|
390
390
|
|
@@ -502,6 +502,6 @@
|
|
502
502
|
|
503
503
|
}
|
504
504
|
|
505
|
-
-----LoginServletはここまでです。
|
505
|
+
!!!!!-----LoginServletはここまでです。
|
506
506
|
|
507
507
|
どうぞよろしくお願いします。
|
2
丁寧な質問に変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,14 +32,14 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
+
----LoginLogicTestです。
|
36
|
+
|
35
37
|
|
36
38
|
|
37
39
|
package test;
|
38
40
|
|
39
41
|
|
40
42
|
|
41
|
-
|
42
|
-
|
43
43
|
import model.Login;
|
44
44
|
|
45
45
|
import model.LoginLogic;
|
@@ -104,7 +104,7 @@
|
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
-
|
107
|
+
-----LoginLogicTestはここまでです。
|
108
108
|
|
109
109
|
|
110
110
|
|
@@ -158,9 +158,7 @@
|
|
158
158
|
|
159
159
|
|
160
160
|
|
161
|
-
|
161
|
+
-----AccountDAOです。
|
162
|
-
|
163
|
-
|
164
162
|
|
165
163
|
|
166
164
|
|
@@ -298,8 +296,6 @@
|
|
298
296
|
|
299
297
|
}
|
300
298
|
|
301
|
-
|
302
|
-
|
303
299
|
|
304
300
|
|
305
301
|
|
@@ -382,13 +378,13 @@
|
|
382
378
|
|
383
379
|
}
|
384
380
|
|
385
|
-
|
381
|
+
---AccountDAOはここまでです。
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
386
|
-
|
387
|
+
-----LoginServletです。
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
388
|
|
393
389
|
package servlet;
|
394
390
|
|
@@ -506,6 +502,6 @@
|
|
506
502
|
|
507
503
|
}
|
508
504
|
|
509
|
-
|
505
|
+
-----LoginServletはここまでです。
|
510
506
|
|
511
507
|
どうぞよろしくお願いします。
|
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,6 +34,86 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
+
package test;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
import model.Login;
|
44
|
+
|
45
|
+
import model.LoginLogic;
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
public class LoginLogicTest {
|
50
|
+
|
51
|
+
public static void main(String[] args){
|
52
|
+
|
53
|
+
testExecute1();//ログイン成功のテスト
|
54
|
+
|
55
|
+
testExecute2();//ログイン失敗のテスト
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
public static void testExecute1(){
|
62
|
+
|
63
|
+
Login login=new Login("minato","1234");
|
64
|
+
|
65
|
+
LoginLogic bo=new LoginLogic();
|
66
|
+
|
67
|
+
boolean result=bo.execute(login);
|
68
|
+
|
69
|
+
if(result){
|
70
|
+
|
71
|
+
System.out.println("testExecute1:成功しました。");
|
72
|
+
|
73
|
+
}else{
|
74
|
+
|
75
|
+
System.out.println("testExecute1:失敗しました。");
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
public static void testExecute2(){
|
84
|
+
|
85
|
+
Login login =new Login("minato","12345");
|
86
|
+
|
87
|
+
LoginLogic bo=new LoginLogic();
|
88
|
+
|
89
|
+
boolean result=bo.execute(login);
|
90
|
+
|
91
|
+
if(!result){
|
92
|
+
|
93
|
+
System.out.println("testExecute2:成功しました。");
|
94
|
+
|
95
|
+
}else{
|
96
|
+
|
97
|
+
System.out.println("testExecute2:失敗しました。");
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
37
117
|
package model;
|
38
118
|
|
39
119
|
|