質問編集履歴

1

誤字

2020/06/29 11:01

投稿

ypk
ypk

スコア80

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
 
44
44
 
45
- DAOに記したユーザーIDとパスワードを入力し、ログインに成功しているにも関わらず、どうしてこのような事態が発生してしまうのでしょうか。
45
+ DAOに記したユーザーIDとパスワードをjspに入力し、ログインに成功しているにも関わらず、どうしてこのような事態が発生してしまうのでしょうか。
46
46
 
47
47
 
48
48
 
@@ -54,6 +54,8 @@
54
54
 
55
55
 
56
56
 
57
+
58
+
57
59
  ▼過去の質問
58
60
 
59
61
  https://teratail.com/questions/273094
@@ -245,3 +247,279 @@
245
247
  </html>
246
248
 
247
249
  ```
250
+
251
+
252
+
253
+
254
+
255
+ ```jsp
256
+
257
+ <%@ page language="java" contentType="text/html; charset=UTF-8"
258
+
259
+ pageEncoding="UTF-8"%>
260
+
261
+ <%@ page import="exam.LoggerTester" %>
262
+
263
+ <% request.setCharacterEncoding("UTF-8"); %>
264
+
265
+ <% String loginErrorMessage = (String)request.getAttribute("loginErrorMessage"); %>
266
+
267
+ <!DOCTYPE html>
268
+
269
+ <html>
270
+
271
+ <head>
272
+
273
+ <meta charset="UTF-8">
274
+
275
+ <title>書籍管理システム-<ログイン></title>
276
+
277
+ <link rel="stylesheet" href="header.css">
278
+
279
+ </head>
280
+
281
+
282
+
283
+ <div class="container">
284
+
285
+ <header>
286
+
287
+
288
+
289
+ <div class="header_logo_font">
290
+
291
+ <p>書籍管理システムログイン</p>
292
+
293
+ </div>
294
+
295
+ </div>
296
+
297
+
298
+
299
+ <hr>
300
+
301
+ </header>
302
+
303
+ <body>
304
+
305
+
306
+
307
+ <%
308
+
309
+ LoggerTester lt = new LoggerTester();
310
+
311
+ lt.outActionLog("login.jsp", "処理開始");
312
+
313
+ %>
314
+
315
+
316
+
317
+ <div class="body">
318
+
319
+ <div class="content">
320
+
321
+ <div align="center">
322
+
323
+ <table border="0">
324
+
325
+ <form action="Login" method="POST">
326
+
327
+
328
+
329
+ <div class="break">
330
+
331
+ <font color="#fff">空欄作成のために使用。画面に映りません。</font>
332
+
333
+ </div>
334
+
335
+
336
+
337
+ <div class="break">
338
+
339
+ <font color="#fff">空欄作成のために使用。画面に映りません。</font>
340
+
341
+ </div>
342
+
343
+
344
+
345
+ <center>
346
+
347
+ <% if(loginErrorMessage != null){ %>
348
+
349
+ <p><font color="red"><%= loginErrorMessage %></font></p>
350
+
351
+ <%} %>
352
+
353
+ </center>
354
+
355
+ <div class="break">
356
+
357
+ <font color="#fff">空欄作成のために使用。画面に映りません。</font>
358
+
359
+ </div>
360
+
361
+
362
+
363
+ <p>ユーザーID
364
+
365
+ <input class="center" type="text" name="user_id" value="" size="24">
366
+
367
+ <p>パスワード
368
+
369
+ <input class="center" type="password" name="password" value="" size="24">
370
+
371
+ <br><br>
372
+
373
+ <input class="login" type="submit" name="login" value="ログイン"></div>
374
+
375
+
376
+
377
+
378
+
379
+ </form>
380
+
381
+ </table>
382
+
383
+
384
+
385
+ </div>
386
+
387
+ </div>
388
+
389
+ </div>
390
+
391
+ </body>
392
+
393
+
394
+
395
+ <footer>
396
+
397
+ <hr>
398
+
399
+
400
+
401
+ </div>
402
+
403
+ </html>
404
+
405
+ ```
406
+
407
+
408
+
409
+ ```DAO
410
+
411
+ package dao;
412
+
413
+
414
+
415
+ import java.io.Serializable;
416
+
417
+ import java.sql.SQLException;
418
+
419
+
420
+
421
+ public class UserDAO implements Serializable {
422
+
423
+
424
+
425
+ //アクセサメソッド
426
+
427
+ private String _loginid;
428
+
429
+ private String _userpassword;
430
+
431
+ private int _admin;
432
+
433
+ private String _name;
434
+
435
+
436
+
437
+ public void setloginid(String loginid) {
438
+
439
+ this._loginid = loginid;
440
+
441
+ }
442
+
443
+ public String getloginid() {
444
+
445
+ return this._loginid;
446
+
447
+ }
448
+
449
+
450
+
451
+ public void setuserpassword(String userpassword) {
452
+
453
+ this._userpassword = userpassword;
454
+
455
+ }
456
+
457
+ public String getuserpassword() {
458
+
459
+ return this._userpassword;
460
+
461
+ }
462
+
463
+
464
+
465
+ public void setadmin(int admin) {
466
+
467
+ this._admin = admin;
468
+
469
+ }
470
+
471
+ public int getadmin() {
472
+
473
+ return this._admin;
474
+
475
+ }
476
+
477
+
478
+
479
+ public void setname(String name) {
480
+
481
+ this._userpassword = name;
482
+
483
+ }
484
+
485
+ public String getname() {
486
+
487
+ return this._name;
488
+
489
+ }
490
+
491
+
492
+
493
+
494
+
495
+ //セットした情報を取得
496
+
497
+ public UserDAO selectUser(String loginid, String userpassword) throws ClassNotFoundException,SQLException{
498
+
499
+
500
+
501
+ UserDAO user = new UserDAO();
502
+
503
+
504
+
505
+ user.setloginid("00014");
506
+
507
+ user.setuserpassword("aaaaaa");
508
+
509
+ user.setadmin(0);
510
+
511
+ user.setname("tarou");
512
+
513
+
514
+
515
+ // 戻り値の設定
516
+
517
+ return user;
518
+
519
+ }
520
+
521
+
522
+
523
+ }
524
+
525
+ ```