質問編集履歴

2

質問の変更

2016/06/21 05:37

投稿

l_l_l_l_l_l_l_l
l_l_l_l_l_l_l_l

スコア38

test CHANGED
File without changes
test CHANGED
@@ -311,15 +311,3 @@
311
311
 
312
312
 
313
313
  ```
314
-
315
-
316
-
317
- ###試したこと
318
-
319
- 課題に対してアプローチしたことを記載してください
320
-
321
-
322
-
323
- ###補足情報(言語/FW/ツール等のバージョンなど)
324
-
325
- より詳細な情報

1

質問の変更

2016/06/21 05:37

投稿

l_l_l_l_l_l_l_l
l_l_l_l_l_l_l_l

スコア38

test CHANGED
@@ -1 +1 @@
1
- 書き方の変え方
1
+ JSP、スクリプトレット
test CHANGED
@@ -1,20 +1,46 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- JSP②のような書き方がしたいのですが???の部分
3
+ 以下構文スクリプトレット使わずに
4
+
4
-
5
+ 記述したい。
6
+
5
- なんと記述していいか分かりません。。。
7
+ また、記述したコードを挿入する
8
+
6
-
9
+ 場所も下記に記載しておきます
10
+
11
+
12
+
13
+ ###変更したいコード
14
+
15
+ ```
16
+
17
+ <%
18
+
19
+ String memo = rs11.getString("note");
20
+
21
+ if (memo == "") {
22
+
23
+ %>-<%
24
+
7
- 間単に言うと<% %>の書き方をやめたいです。
25
+ } else if (memo == null) {
26
+
8
-
27
+ %>-<%
28
+
9
-
29
+ } else {
30
+
10
-
31
+ %><%=rs11.getString("note")%>
32
+
33
+ ```
34
+
35
+
36
+
11
- ###
37
+ ###挿入先JSP
12
38
 
13
39
  ```ここに言語を入力
14
40
 
15
41
  <%@ page contentType="text/html; charset=UTF-8"
16
42
 
17
- import="java.sql.*,javax.naming.*,javax.sql.*,java.text.*,javax.servlet.http.HttpSession"%>
43
+ import="java.sql.*,javax.naming.*,javax.sql.*,java.text.*,java.util.Date,java.util.Calendar"%>
18
44
 
19
45
  <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
20
46
 
@@ -28,17 +54,17 @@
28
54
 
29
55
  <sql:query var="rs" dataSource="${db}">
30
56
 
31
- SELECT book.book_no,book.book_name,genre.genre_name,
57
+ SELECT book.book_no,book.book_name,book.note,genre.genre_name,
32
58
 
33
59
  lend.lend_date,book.state FROM book LEFT JOIN lend ON book.book_no = lend.book_no LEFT JOIN
34
60
 
35
- user ON user.user_no = lend.user_no LEFT JOIN genre ON book.genre_no = genre.genre_no
61
+ user ON user.user_no = lend.user_no LEFT JOIN genre ON book.genre_no = genre.genre_no where book.delete_flg = 0
36
62
 
37
63
 
38
64
 
39
65
  <c:if test="${!empty param['genreNo']}">
40
66
 
41
- where book.genre_no = ?
67
+ and book.genre_no = ?
42
68
 
43
69
  <sql:param value="${param['genreNo']}" />
44
70
 
@@ -54,6 +80,14 @@
54
80
 
55
81
  </sql:query>
56
82
 
83
+ <sql:query var="rs2" dataSource="${db}">
84
+
85
+ select book.book_no from book
86
+
87
+ </sql:query>
88
+
89
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
90
+
57
91
 
58
92
 
59
93
 
@@ -78,517 +112,211 @@
78
112
 
79
113
  <form method="POST" action="book_kanri.jsp">
80
114
 
81
- <%
82
-
83
- Connection con = null;
84
-
85
- PreparedStatement ps = null;
86
-
87
- String sql = null;
88
-
89
- ResultSet rs = null;
90
-
91
- try {
92
-
93
- Context initContext = new InitialContext();
94
-
95
- DataSource ds = (DataSource) initContext
96
-
97
- .lookup("java:comp/env/jdbc/Library");
98
-
99
- con = ds.getConnection();
100
-
101
-
102
-
103
- sql = "SELECT book.book_no,book.book_name,genre.genre_name,book.state"
104
-
105
- + " FROM book LEFT JOIN genre ON book.genre_no = genre.genre_no where book.delete_flg = 0";
106
-
107
-
108
-
109
- ps = con.prepareStatement(sql);
110
-
111
-
112
-
113
- rs = ps.executeQuery();
114
-
115
- %>
116
-
117
- <p>
118
-
119
- ジャンル <select name="genreno">
120
-
121
- <option value="">全て</option>
122
-
123
- <c:forEach var="row" items="${rs1.rows}">
124
-
125
- <option value=${row.genre_no}>${row.genre_name}</option>
126
-
127
- </c:forEach>
128
-
129
- </select>
130
-
131
-
132
-
133
- <button style="color: white; background-color: D57200;"
134
-
135
- class="button" type="submit">絞り込む</button>
136
-
137
- </p>
138
-
139
- </form>
140
-
141
- <br>
142
-
143
- <table class="tbl_01" border="1">
144
-
145
- <tr>
146
-
147
- <th>書籍ID</th>
148
-
149
- <th>書籍名</th>
150
-
151
- <th>ジャンル</th>
152
-
153
- <th>貸出</th>
154
-
155
- <th>貸出変更</th>
156
-
157
- <th>削除</th>
158
-
159
- </tr>
160
-
161
- <tr>
162
-
163
- <%
164
-
165
- while (rs.next()) {
166
-
167
- %>
168
-
169
- <td><%=rs.getString("book_no")%></td>
170
-
171
- <td><%=rs.getString("book_name")%></td>
172
-
173
- <td><%=rs.getString("genre_name")%></td>
174
-
175
- <td>
176
-
177
- <%
178
-
179
- String str = rs.getString("state");
180
-
181
- if ("1".equals(str)) {
182
-
183
- %>○<%
184
-
185
- } else {
186
-
187
- %>×<%
188
-
189
- }
190
-
191
- %>
192
-
193
- </td>
194
-
195
-
196
-
197
- <%
198
-
199
- if ("1".equals(str)) {
200
-
201
- %><td><form method="POST" action="kano">
202
-
203
-
204
-
205
- <input type="hidden" name="id" value="<%=rs.getString("book_no")%>">
206
-
207
- <button class="button" type="submit">不可へ</button>
208
-
209
- </form></td>
210
-
211
- <%
212
-
213
- } else {
214
-
215
- %>
216
-
217
- <td><form method="POST" action="huka">
218
-
219
- <input type="hidden" name="id" value="<%=rs.getString("book_no")%>">
220
-
221
- <button class="button" type="submit">可能へ</button>
222
-
223
- </form></td>
224
-
225
- <%
226
-
227
- }
228
-
229
- %>
230
-
231
- <td><form method="POST" action="deletebook">
232
-
233
- <input type="hidden" name="user_edit" value="<%=rs.getString("book_no")%>">
234
-
235
- <button class="button" type="submit">削除</button>
236
-
237
- </form></td>
238
-
239
-
240
-
241
-
242
-
243
- </tr>
244
-
245
- <%
246
-
247
- }
248
-
249
- %>
250
-
251
-
252
-
253
- <%
254
-
255
- } catch (Exception e) {
256
-
257
- throw new ServletException(e);
258
-
259
- } finally {
260
-
261
- try {
262
-
263
- if (rs != null) {
264
-
265
- rs.close();
266
-
267
- }
268
-
269
- if (ps != null) {
270
-
271
- ps.close();
272
-
273
- }
274
-
275
- if (con != null) {
276
-
277
- con.close();
278
-
279
- }
280
-
281
- } catch (Exception e) {
282
-
283
- }
284
-
285
- }
286
-
287
- %>
288
-
289
- </table>
290
-
291
- <br>
292
-
293
- <form action="book_resurrection.jsp">
294
-
295
- <input style="color: white; background-color: D57200;" type="submit"
296
-
297
- name="reset2" value="削除済書籍編集">
298
-
299
- </form>
300
-
301
- <form action="kanri_mypage.jsp">
302
-
303
- <input style="color: white; background-color: D57200;" type="submit"
304
-
305
- name="mypage" value="TOPページ">
306
-
307
- </form>
115
+
116
+
117
+ <br>
118
+
119
+ <form method="POST" action="book_kanri.jsp">
120
+
121
+ <p>
122
+
123
+ ジャンル <select name="genreNo">
124
+
125
+ <option value="">全て</option>
126
+
127
+ <c:forEach var="row" items="${rs1.rows}">
128
+
129
+ <option value=${row.genre_no}>${row.genre_name}</option>
130
+
131
+ </c:forEach>
132
+
133
+ </select>
134
+
135
+ </p>
136
+
137
+
138
+
139
+ <INPUT style="color: white; background-color: D57200;" type="submit"
140
+
141
+ value="絞り込む" />
142
+
143
+ </form>
144
+
145
+ <br> <br>
146
+
147
+ <form method="POST" action="book_memo">
148
+
149
+
150
+
151
+ <p>
152
+
153
+ 書籍ID <select name="book_no">
154
+
155
+ <c:forEach var="row" items="${rs2.rows}">
156
+
157
+ <option>${row.book_no}</option>
158
+
159
+ </c:forEach>
160
+
161
+ </select>
162
+
163
+ </p>
164
+
165
+ <div>
166
+
167
+ 備考<input type="text" name="note" />
168
+
169
+ </div>
170
+
171
+ <br> <INPUT style="color: white; background-color: D57200;"
172
+
173
+ type="submit" value="登録" />
174
+
175
+ </form>
176
+
177
+ <br>
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+ <table class="tbl_01" border="1">
186
+
187
+ <tr>
188
+
189
+ <th>書籍ID</th>
190
+
191
+ <th>書籍名</th>
192
+
193
+ <th>ジャンル</th>
194
+
195
+ <th>貸出</th>
196
+
197
+ <th>貸出変更</th>
198
+
199
+ <th>削除</th>
200
+
201
+ <th>備考(メモ)</th>
202
+
203
+ </tr>
204
+
205
+ <c:forEach var="row" items="${rs.rows}">
206
+
207
+ <tr>
208
+
209
+
210
+
211
+ <td>${row.book_no}</td>
212
+
213
+ <td>${row.book_name}</td>
214
+
215
+ <td>${row.genre_name}</td>
216
+
217
+ <td><c:if test="${row.state == 1}">○</c:if> <c:if
218
+
219
+ test="${row.state != 1}">×</c:if></td>
220
+
221
+ <c:if test="${row.state == 1}">
222
+
223
+ <td><form method="POST" action="kano">
224
+
225
+
226
+
227
+ <input type="hidden" name="id" value=${row.book_no}>
228
+
229
+ <button class="button" type="submit">不可へ</button>
230
+
231
+ </form></td>
232
+
233
+ </c:if>
234
+
235
+ <c:if test="${row.state != 1}">
236
+
237
+ <td><form method="POST" action="huka">
238
+
239
+
240
+
241
+ <input type="hidden" name="id" value=${row.book_no}>
242
+
243
+ <button class="button" type="submit">可能へ</button>
244
+
245
+ </form></td>
246
+
247
+ </c:if>
248
+
249
+ <td><form method="POST" action="delete_book">
250
+
251
+ <input type="hidden" name="user_edit" value=${row.book_no}>
252
+
253
+ <button class="button" type="submit">削除</button>
254
+
255
+ </form></td>
256
+
257
+ <td>
258
+
259
+
260
+
261
+ ===============ここに挿入=======================
262
+
263
+
264
+
265
+ </td>
266
+
267
+ </tr>
268
+
269
+ </c:forEach>
270
+
271
+ </table>
272
+
273
+ <br>
274
+
275
+ <form action="kanri_mypage.jsp">
276
+
277
+ <input style="color: white; background-color: D57200;" type="submit"
278
+
279
+ name="mypage" value="TOPページ">
280
+
281
+
282
+
283
+ </form>
284
+
285
+
286
+
287
+ <form action="book_resurrection.jsp">
288
+
289
+ <input style="color: white; background-color: D57200;" type="submit"
290
+
291
+ name="reset2" value="削除済書籍編集">
292
+
293
+ </form>
294
+
295
+
296
+
297
+ <c:if test="${!empty requestScope['errorMessage']}">
298
+
299
+ <div>${requestScope['errorMessage']}</div>
300
+
301
+ </c:if>
302
+
303
+
308
304
 
309
305
  </body>
310
306
 
311
307
  </html>
312
308
 
309
+ /
310
+
311
+
312
+
313
313
  ```
314
314
 
315
315
 
316
316
 
317
- ###
317
+ ###試したこと
318
-
319
- ```
318
+
320
-
321
- <%@ page contentType="text/html; charset=UTF-8"
322
-
323
- import="java.sql.*,javax.naming.*,javax.sql.*,java.text.*,java.util.Date,java.util.Calendar"%>
324
-
325
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
326
-
327
- <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
328
-
329
- <html>
330
-
331
- <sql:setDataSource var="db" driver="com.mysql.jdbc.Driver"
332
-
333
- url="jdbc:mysql://localhost/Library" user="root" password="" />
334
-
335
- <sql:query var="rs" dataSource="${db}">
336
-
337
- SELECT book.book_no,book.book_name,book.note,genre.genre_name,
338
-
339
- lend.lend_date,book.state FROM book LEFT JOIN lend ON book.book_no = lend.book_no LEFT JOIN
340
-
341
- user ON user.user_no = lend.user_no LEFT JOIN genre ON book.genre_no = genre.genre_no where book.delete_flg = 0
342
-
343
-
344
-
345
- <c:if test="${!empty param['genreNo']}">
346
-
347
- and book.genre_no = ?
348
-
349
- <sql:param value="${param['genreNo']}" />
350
-
351
- </c:if>
352
-
353
- ORDER BY book.book_no;
354
-
355
- </sql:query>
319
+ 課題に対してアプローチしたことを記載してください
356
-
357
- <sql:query var="rs1" dataSource="${db}">
358
-
359
- select * from genre
360
-
361
- </sql:query>
362
-
363
- <sql:query var="rs2" dataSource="${db}">
364
-
365
- select book.book_no from book
366
-
367
- </sql:query>
368
-
369
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
370
-
371
-
372
-
373
-
374
-
375
- <head>
376
-
377
- <link rel="stylesheet" type="text/css" href="css/Library.css">
378
-
379
- <meta content="text/html; charset=UTF-8">
380
-
381
- <title>書籍管理画面</title>
382
-
383
- </head>
384
-
385
- <body>
386
-
387
- <h2>書籍管理画面</h2>
388
-
389
-
390
-
391
- <br>
392
-
393
- <form method="POST" action="book_kanri.jsp">
394
-
395
-
396
-
397
- <br>
398
-
399
- <form method="POST" action="book_kanri.jsp">
400
-
401
- <p>
402
-
403
- ジャンル <select name="genreNo">
404
-
405
- <option value="">全て</option>
406
-
407
- <c:forEach var="row" items="${rs1.rows}">
408
-
409
- <option value=${row.genre_no}>${row.genre_name}</option>
410
-
411
- </c:forEach>
412
-
413
- </select>
414
-
415
- </p>
416
-
417
-
418
-
419
- <INPUT style="color: white; background-color: D57200;" type="submit"
420
-
421
- value="絞り込む" />
422
-
423
- </form>
424
-
425
- <br> <br>
426
-
427
- <form method="POST" action="book_memo">
428
-
429
-
430
-
431
- <p>
432
-
433
- 書籍ID <select name="book_no">
434
-
435
- <c:forEach var="row" items="${rs2.rows}">
436
-
437
- <option>${row.book_no}</option>
438
-
439
- </c:forEach>
440
-
441
- </select>
442
-
443
- </p>
444
-
445
- <div>
446
-
447
- 備考<input type="text" name="note" />
448
-
449
- </div>
450
-
451
- <br> <INPUT style="color: white; background-color: D57200;"
452
-
453
- type="submit" value="登録" />
454
-
455
- </form>
456
-
457
- <br>
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
- <table class="tbl_01" border="1">
466
-
467
- <tr>
468
-
469
- <th>書籍ID</th>
470
-
471
- <th>書籍名</th>
472
-
473
- <th>ジャンル</th>
474
-
475
- <th>貸出</th>
476
-
477
- <th>貸出変更</th>
478
-
479
- <th>削除</th>
480
-
481
- <th>備考(メモ)</th>
482
-
483
- </tr>
484
-
485
- <c:forEach var="row" items="${rs.rows}">
486
-
487
- <tr>
488
-
489
-
490
-
491
- <td>${row.book_no}</td>
492
-
493
- <td>${row.book_name}</td>
494
-
495
- <td>${row.genre_name}</td>
496
-
497
- <td><c:if test="${row.state == 1}">○</c:if> <c:if
498
-
499
- test="${row.state != 1}">×</c:if></td>
500
-
501
- <c:if test="${row.state == 1}">
502
-
503
- <td><form method="POST" action="kano">
504
-
505
-
506
-
507
- <input type="hidden" name="id" value=${row.book_no}>
508
-
509
- <button class="button" type="submit">不可へ</button>
510
-
511
- </form></td>
512
-
513
- </c:if>
514
-
515
- <c:if test="${row.state != 1}">
516
-
517
- <td><form method="POST" action="huka">
518
-
519
-
520
-
521
- <input type="hidden" name="id" value=${row.book_no}>
522
-
523
- <button class="button" type="submit">可能へ</button>
524
-
525
- </form></td>
526
-
527
- </c:if>
528
-
529
- <td><form method="POST" action="delete_book">
530
-
531
- <input type="hidden" name="user_edit" value=${row.book_no}>
532
-
533
- <button class="button" type="submit">削除</button>
534
-
535
- </form></td>
536
-
537
- <td>
538
-
539
-
540
-
541
-
542
-
543
- ??????????????????
544
-
545
-
546
-
547
- </td>
548
-
549
-
550
-
551
- </tr>
552
-
553
- </c:forEach>
554
-
555
- </table>
556
-
557
- <br>
558
-
559
- <form action="kanri_mypage.jsp">
560
-
561
- <input style="color: white; background-color: D57200;" type="submit"
562
-
563
- name="mypage" value="TOPページ">
564
-
565
-
566
-
567
- </form>
568
-
569
-
570
-
571
- <form action="book_resurrection.jsp">
572
-
573
- <input style="color: white; background-color: D57200;" type="submit"
574
-
575
- name="reset2" value="削除済書籍編集">
576
-
577
- </form>
578
-
579
-
580
-
581
- <c:if test="${!empty requestScope['errorMessage']}">
582
-
583
- <div>${requestScope['errorMessage']}</div>
584
-
585
- </c:if>
586
-
587
- </body>
588
-
589
- </html>
590
-
591
- ```
592
320
 
593
321
 
594
322