質問編集履歴
1
codeごとに分類及び xmlの追加(
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,11 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
+
|
26
|
+
|
25
|
-
```J
|
27
|
+
```Jsp
|
28
|
+
|
29
|
+
#login.jsp
|
26
30
|
|
27
31
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
28
32
|
|
@@ -56,11 +60,13 @@
|
|
56
60
|
|
57
61
|
</html>
|
58
62
|
|
59
|
-
|
63
|
+
```
|
60
|
-
|
64
|
+
|
65
|
+
|
66
|
+
|
61
|
-
|
67
|
+
```Servlet
|
62
|
-
|
68
|
+
|
63
|
-
|
69
|
+
//Control.java
|
64
70
|
|
65
71
|
import java.io.IOException;
|
66
72
|
|
@@ -254,122 +260,294 @@
|
|
254
260
|
|
255
261
|
|
256
262
|
|
257
|
-
|
258
|
-
|
259
|
-
|
263
|
+
```
|
260
|
-
|
264
|
+
|
261
|
-
|
265
|
+
```class
|
262
|
-
|
266
|
+
|
263
|
-
|
267
|
+
///UserOrderBean.java
|
264
|
-
|
265
|
-
|
266
|
-
|
268
|
+
|
267
|
-
import
|
269
|
+
import mode.UserBean;
|
268
|
-
|
269
|
-
|
270
|
-
|
270
|
+
|
271
|
+
|
272
|
+
|
271
|
-
public class UserBean
|
273
|
+
public class UserOrderBean {
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
274
|
+
|
276
|
-
|
277
|
-
|
275
|
+
|
278
|
-
|
279
|
-
|
276
|
+
|
280
|
-
|
281
|
-
private String[] product;
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
/** Creates a new instance of UserBean */
|
286
|
-
|
287
|
-
|
277
|
+
public UserOrderBean() {
|
288
|
-
|
289
|
-
|
278
|
+
|
290
|
-
|
291
|
-
|
279
|
+
|
292
|
-
|
293
|
-
}
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
public String getaName() {
|
298
|
-
|
299
|
-
return name;
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
public void setaName(String na) {
|
306
|
-
|
307
|
-
name = na;
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
public String getPassword() {
|
314
|
-
|
315
|
-
return password;
|
316
|
-
|
317
|
-
}
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
public void setPassword(String ps) {
|
322
|
-
|
323
|
-
password = ps;
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
public String getAddress() {
|
330
|
-
|
331
|
-
return address;
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
public void setAddress(String adr) {
|
338
|
-
|
339
|
-
address = adr;
|
340
|
-
|
341
|
-
}
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
public String[] getProduct() {
|
346
|
-
|
347
|
-
return product;
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
public void setProduct(String[] product) {
|
354
|
-
|
355
|
-
this.product = product;
|
356
|
-
|
357
|
-
}
|
358
280
|
|
359
281
|
}
|
360
282
|
|
361
283
|
|
362
284
|
|
285
|
+
public boolean execute(UserBean ub) {
|
286
|
+
|
287
|
+
String[] product = ub.getProduct();
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
//FORM情報が入力されているかチェック
|
292
|
+
|
293
|
+
if (ub.getaName().equals("taro")==true && ub.getPassword().equals("taro")==true) {
|
294
|
+
|
295
|
+
return true;
|
296
|
+
|
297
|
+
//入力されていない場合
|
298
|
+
|
299
|
+
ub.setProduct(new String[0]);
|
300
|
+
|
301
|
+
return false;
|
302
|
+
|
303
|
+
} else {
|
304
|
+
|
305
|
+
//入力されている場合
|
306
|
+
|
307
|
+
return true;
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
```
|
328
|
+
|
329
|
+
```class
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
import javax.servlet.http.HttpSession;
|
334
|
+
|
335
|
+
import javax.servlet.jsp.JspWriter;
|
336
|
+
|
337
|
+
import javax.servlet.jsp.tagext.TagSupport;
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
public class OrderHandler extends TagSupport {
|
342
|
+
|
343
|
+
public int doEndTag() {
|
344
|
+
|
345
|
+
HttpSession session = pageContext.getSession();
|
346
|
+
|
347
|
+
//String[] product = (String[])session.getAttribute("userbeanses");
|
348
|
+
|
349
|
+
UserBean ub
|
350
|
+
|
351
|
+
= (UserBean) session.getAttribute("userbeanses");
|
352
|
+
|
353
|
+
String[] product = ub.getProduct();
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
JspWriter out = pageContext.getOut();
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
try {
|
362
|
+
|
363
|
+
out.println("<TR><TD>Name</TD></TR>");
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
for (int i = 0; i < product.length; i++) {
|
368
|
+
|
369
|
+
out.print("<TR><TD>");
|
370
|
+
|
371
|
+
out.print(product[i]);
|
372
|
+
|
373
|
+
out.print("</TD></TR>");
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
} catch (Exception e) {
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
return EVAL_PAGE;
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
/** Creates a new instance of OrderHandler */
|
388
|
+
|
389
|
+
public OrderHandler() {
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
```
|
402
|
+
|
403
|
+
```class
|
404
|
+
|
405
|
+
//OrderHandier.java
|
406
|
+
|
407
|
+
import javax.servlet.http.HttpSession;
|
408
|
+
|
409
|
+
import javax.servlet.jsp.JspWriter;
|
410
|
+
|
411
|
+
import javax.servlet.jsp.tagext.TagSupport;
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
public class OrderHandler extends TagSupport {
|
416
|
+
|
417
|
+
public int doEndTag() {
|
418
|
+
|
419
|
+
HttpSession session = pageContext.getSession();
|
420
|
+
|
421
|
+
//String[] product = (String[])session.getAttribute("userbeanses");
|
422
|
+
|
423
|
+
UserBean ub
|
424
|
+
|
425
|
+
= (UserBean) session.getAttribute("userbeanses");
|
426
|
+
|
427
|
+
String[] product = ub.getProduct();
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
JspWriter out = pageContext.getOut();
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
try {
|
436
|
+
|
437
|
+
out.println("<TR><TD>Name</TD></TR>");
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
for (int i = 0; i < product.length; i++) {
|
442
|
+
|
443
|
+
out.print("<TR><TD>");
|
444
|
+
|
445
|
+
out.print(product[i]);
|
446
|
+
|
447
|
+
out.print("</TD></TR>");
|
448
|
+
|
449
|
+
}
|
450
|
+
|
451
|
+
} catch (Exception e) {
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
return EVAL_PAGE;
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
/** Creates a new instance of OrderHandler */
|
462
|
+
|
463
|
+
public OrderHandler() {
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
```
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
```xml
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
484
|
+
|
485
|
+
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
|
486
|
+
|
487
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
|
488
|
+
|
489
|
+
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
490
|
+
|
491
|
+
<servlet>
|
492
|
+
|
493
|
+
<servlet-name>Control</servlet-name>
|
494
|
+
|
495
|
+
<servlet-class>webApplication27.Control</servlet-class>
|
496
|
+
|
497
|
+
</servlet>
|
498
|
+
|
499
|
+
<servlet-mapping>
|
500
|
+
|
501
|
+
<servlet-name>Control</servlet-name>
|
502
|
+
|
503
|
+
<url-pattern>/Control</url-pattern>
|
504
|
+
|
505
|
+
</servlet-mapping>
|
506
|
+
|
507
|
+
<jsp-config>
|
508
|
+
|
509
|
+
<taglib>
|
510
|
+
|
511
|
+
<taglib-uri>/OrderLibrary</taglib-uri>
|
512
|
+
|
513
|
+
<taglib-location>/WEB-INF/tlds/order.tld</taglib-location>
|
514
|
+
|
515
|
+
</taglib>
|
516
|
+
|
517
|
+
</jsp-config>
|
518
|
+
|
519
|
+
<session-config>
|
520
|
+
|
521
|
+
<session-timeout>30</session-timeout>
|
522
|
+
|
523
|
+
</session-config>
|
524
|
+
|
525
|
+
<welcome-file-list>
|
526
|
+
|
527
|
+
<welcome-file>index.jsp</welcome-file>
|
528
|
+
|
529
|
+
</welcome-file-list>
|
530
|
+
|
531
|
+
</web-app>
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
```
|
536
|
+
|
537
|
+
|
538
|
+
|
363
539
|
### 試したこと
|
364
540
|
|
365
541
|
リクエストセッション
|
366
542
|
|
367
|
-
|
368
|
-
|
369
543
|
|
370
544
|
|
371
545
|
### 補足情報(FW/ツールのバージョンなど)
|
372
546
|
|
373
|
-
|
547
|
+
参考にしたリンク先
|
548
|
+
|
374
|
-
|
549
|
+
[JSPとサーブレットを利用した注文アプリケーションのサンプル ](https://www.ipentec.com/document/java-servlet-bean-order-app)]
|
550
|
+
|
551
|
+
|
552
|
+
|
375
|
-
環境エクリプス javaEE
|
553
|
+
環境エクリプス javaEE TOMcat-8.0.39 エクリプス内のものを使用
|