質問編集履歴
8
誤字
title
CHANGED
|
@@ -1,1 +1,1 @@
|
|
|
1
|
-
|
|
1
|
+
サーブレットからJSPの受け渡しがうまくいかないです。
|
body
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
###前提・実現したいこと
|
|
2
2
|
プログラミング、java共に初心者です。
|
|
3
|
-
授業で部署の管理システムというものを作っており、
|
|
4
|
-
画面でコードと部署名を入力し、
|
|
5
|
-
登録ボタンを押すとコードと部署名の追加と変更を行う、
|
|
6
|
-
|
|
3
|
+
授業でサーブレットからJSPに画面遷移するプログラムを作ろうとしています。
|
|
7
|
-
|
|
8
4
|
###発生している問題・エラーメッセージ
|
|
9
5
|
Initを実行すると、初期表示はされるのですが、何も入力せずに登録ボタンを押す、
|
|
10
|
-
また
|
|
6
|
+
またコード、部署名を入力し追加ボタンを押してもHTTPステータス404(The requested resource is not available.) が表示されエラーになってしまう状態です。
|
|
11
7
|
|
|
12
8
|
まだjavaのことを理解しておらず、どこのソースがどのように動いているのかすら全て把握していないため、余分な部分も
|
|
13
9
|
多々混ざっているかもしれません。
|
|
@@ -19,7 +15,7 @@
|
|
|
19
15
|
|
|
20
16
|
###該当のソースコード(init)
|
|
21
17
|
```lang-言語名
|
|
22
|
-
package
|
|
18
|
+
package kanri;
|
|
23
19
|
|
|
24
20
|
import java.io.IOException;
|
|
25
21
|
import java.sql.Connection;
|
|
@@ -54,7 +50,7 @@
|
|
|
54
50
|
|
|
55
51
|
request.setCharacterEncoding("UTF-8");
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
|
|
58
54
|
|
|
59
55
|
|
|
60
56
|
|
|
@@ -69,7 +65,7 @@
|
|
|
69
65
|
String dept_name = rs.getString("D_NAME");
|
|
70
66
|
|
|
71
67
|
//
|
|
72
|
-
|
|
68
|
+
D bean = new Dept();
|
|
73
69
|
bean.setDno(d_no);
|
|
74
70
|
bean.setDname(d_name);
|
|
75
71
|
//
|
|
@@ -78,22 +74,13 @@
|
|
|
78
74
|
//
|
|
79
75
|
|
|
80
76
|
request.setAttribute("depts", d_list);
|
|
81
|
-
RequestDispatcher rd = request.getRequestDispatcher("
|
|
77
|
+
RequestDispatcher rd = request.getRequestDispatcher("001.jsp");
|
|
82
78
|
rd.forward(request, response);
|
|
83
79
|
|
|
84
|
-
|
|
80
|
+
|
|
85
|
-
|
|
81
|
+
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
finally {
|
|
89
|
-
try {
|
|
90
|
-
conn.close();
|
|
91
|
-
} catch (Exception ex) {
|
|
92
|
-
;
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
84
|
}
|
|
98
85
|
|
|
99
86
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
@@ -103,132 +90,27 @@
|
|
|
103
90
|
}
|
|
104
91
|
}
|
|
105
92
|
```
|
|
106
|
-
###該当のソースコード(Insert)
|
|
107
|
-
```lang-言語名
|
|
108
|
-
package seminar;
|
|
109
93
|
|
|
110
|
-
import java.io.IOException;
|
|
111
|
-
import java.sql.Connection;
|
|
112
|
-
import java.sql.PreparedStatement;
|
|
113
|
-
|
|
114
|
-
import javax.servlet.RequestDispatcher;
|
|
115
|
-
import javax.servlet.ServletException;
|
|
116
|
-
import javax.servlet.http.HttpServlet;
|
|
117
|
-
import javax.servlet.http.HttpServletRequest;
|
|
118
|
-
import javax.servlet.http.HttpServletResponse;
|
|
119
|
-
|
|
120
|
-
public class Insert extends HttpServlet {
|
|
121
|
-
private static final long serialVersionUID = 1L;
|
|
122
|
-
|
|
123
|
-
public Insert() {
|
|
124
|
-
super();
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
|
129
|
-
throws ServletException, IOException {
|
|
130
|
-
|
|
131
|
-
Connection conn = null;
|
|
132
|
-
String sql = "insert into (D_NO,D_NAME)values(?, ?)";
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
if (request.getCharacterEncoding() == null) {
|
|
136
|
-
request.setCharacterEncoding("UTF-8");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
String pm_no = request.getParameter("fg");
|
|
140
|
-
String pm_name = request.getParameter("dname");
|
|
141
|
-
String tourokuFlag = request.getParameter("fg");
|
|
142
|
-
|
|
143
|
-
DeptBean bean = new Dept();
|
|
144
|
-
bean.setDeptno(p_no);
|
|
145
|
-
bean.setDname(p_name);
|
|
146
|
-
|
|
147
|
-
boolean is_error = false;
|
|
148
|
-
|
|
149
|
-
if (Fg != null) {
|
|
150
|
-
|
|
151
|
-
if (bean.getDno() == null ||
|
|
152
|
-
bean.getDname() == null ||
|
|
153
|
-
bean.getDno().trim().equals("")||
|
|
154
|
-
bean.getDname().trim().equals("")
|
|
155
|
-
) {
|
|
156
|
-
is_error = true;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
request.setAttribute("dept", bean);
|
|
160
|
-
|
|
161
|
-
String jsp = "03.jsp";
|
|
162
|
-
if (is_error) {
|
|
163
|
-
jsp = "03.jsp";
|
|
164
|
-
request.setAttribute("err_msg", "データが全て入力されていません");
|
|
165
|
-
}
|
|
166
|
-
RequestDispatcher rd = request.getRequestDispatcher(jsp_page);
|
|
167
|
-
rd.forward(request, response);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
conn = Uty.getConnection();
|
|
172
|
-
PreparedStatement ppst = conn.prepareStatement(sql);
|
|
173
|
-
ppst.setString(1,bean.getDno());
|
|
174
|
-
ppst.setString(2,bean.getDname());
|
|
175
|
-
int count = ppst.executeUpdate();
|
|
176
|
-
conn.close();
|
|
177
|
-
|
|
178
|
-
String msg = "完了しました";
|
|
179
|
-
if(count < 1){
|
|
180
|
-
msg = "エラー";
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
request.setAttribute("dept",bean);
|
|
184
|
-
request.setAttribute("err_msg",msg);
|
|
185
|
-
|
|
186
|
-
RequestDispatcher rd = request.getRequestDispatcher("03.jsp");
|
|
187
|
-
rd.forward(request,response);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
catch (Exception ex) {
|
|
192
|
-
ex.printStackTrace();
|
|
193
|
-
}
|
|
194
|
-
finally {
|
|
195
|
-
try {
|
|
196
|
-
conn.close();
|
|
197
|
-
} catch (Exception ex) {
|
|
198
|
-
;
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
205
|
-
throws ServletException, IOException {
|
|
206
|
-
|
|
207
|
-
doGet(request, response);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
94
|
###該当のソースコード(Class Dept)
|
|
213
95
|
```lang-言語名
|
|
214
96
|
package kanri;
|
|
215
97
|
|
|
216
|
-
public class
|
|
98
|
+
public class Dt{
|
|
217
99
|
|
|
218
100
|
|
|
219
101
|
private String m_no = "";
|
|
220
102
|
|
|
221
|
-
public String
|
|
103
|
+
public String getDno() {
|
|
222
104
|
return this.m_no;
|
|
223
105
|
|
|
224
106
|
}
|
|
225
107
|
|
|
226
|
-
public void
|
|
108
|
+
public void setDno(String dno) {
|
|
227
109
|
this.m_no = dno;
|
|
228
110
|
|
|
229
111
|
}
|
|
230
112
|
|
|
231
|
-
private String
|
|
113
|
+
private String m_name = "";
|
|
232
114
|
|
|
233
115
|
public String getDname() {
|
|
234
116
|
return this.m_name;
|
|
@@ -245,41 +127,7 @@
|
|
|
245
127
|
}
|
|
246
128
|
|
|
247
129
|
```
|
|
248
|
-
###該当のソースコード(class Uty)
|
|
249
|
-
```lang-言語名
|
|
250
|
-
package kanri;
|
|
251
130
|
|
|
252
|
-
import java.sql.Connection;
|
|
253
|
-
import java.sql.ResultSet;
|
|
254
|
-
import java.sql.SQLException;
|
|
255
|
-
|
|
256
|
-
import javax.naming.Context;
|
|
257
|
-
import javax.naming.NamingException;
|
|
258
|
-
import javax.sql.DataSource;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
public class Uty {
|
|
262
|
-
|
|
263
|
-
public static Connection getConnection() throws NamingException, SQLException{
|
|
264
|
-
String judi_url = "java:comp/env/jdbc/sample";
|
|
265
|
-
Context ctx = new javax.naming.InitialContext();
|
|
266
|
-
DataSource ds = (javax.sql.DataSource)ctx.lookup(judi_url);
|
|
267
|
-
Connection conn =ds.getConnection();
|
|
268
|
-
return conn;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
public static void setDeptBeanFromRs(Deptbean,ResultSet rs) throws SQLException{
|
|
274
|
-
|
|
275
|
-
bean.setDeptno(rs.getString("NO"));
|
|
276
|
-
bean.setDeptname(rs.getString("NAME"));
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
```
|
|
282
|
-
|
|
283
131
|
###該当のソースコード(JSP)
|
|
284
132
|
```lang-言語名
|
|
285
133
|
|
|
@@ -309,29 +157,20 @@
|
|
|
309
157
|
<table>
|
|
310
158
|
<tr>
|
|
311
159
|
|
|
312
|
-
<td>
|
|
160
|
+
<td>コード</td>
|
|
313
|
-
<td><input type="text" name="
|
|
161
|
+
<td><input type="text" name="no" ></td>
|
|
314
162
|
<td width = 30>
|
|
315
163
|
<td><button type="submit" name="fg"> 登 録</button></td>
|
|
316
164
|
</tr>
|
|
317
|
-
|
|
165
|
+
|
|
318
|
-
<td>部署名</td>
|
|
319
|
-
<td> <input type="text" name="dname"></td>
|
|
320
|
-
<td width = 30>
|
|
321
|
-
<td><button type="submit" >変 更</button></td>
|
|
322
166
|
|
|
323
|
-
|
|
324
167
|
</tr>
|
|
325
168
|
</table>
|
|
326
169
|
</center>
|
|
327
170
|
</form>
|
|
328
|
-
<br>
|
|
329
|
-
|
|
330
|
-
|
|
331
171
|
<form method="post" action="Init">
|
|
332
|
-
<center>
|
|
172
|
+
<center>
|
|
333
|
-
|
|
334
|
-
<table border=1 height="300" width="350"
|
|
173
|
+
<table border=1 height="300" width="350">
|
|
335
174
|
|
|
336
175
|
<tr bgcolor="#4169e1">
|
|
337
176
|
|
|
@@ -340,40 +179,17 @@
|
|
|
340
179
|
<th width="30">部署</th>
|
|
341
180
|
|
|
342
181
|
|
|
343
|
-
<c:forEach var="dept" items="${depts}">
|
|
344
|
-
<tr>
|
|
345
|
-
<td style = "width:3px">
|
|
346
|
-
<input type="checkbox" class="ck" onclick="connecttext('textforscb3',this.checked);" /></td>
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
<td>${dept.dno}</td>
|
|
352
|
-
<td>${dept.dname}</td>
|
|
353
|
-
|
|
354
|
-
</tr>
|
|
355
|
-
</c:forEach>
|
|
356
|
-
|
|
357
182
|
</table>
|
|
358
183
|
</div>
|
|
359
184
|
|
|
360
185
|
</center>
|
|
361
186
|
</form>
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
<br>
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
187
|
</body>
|
|
369
|
-
|
|
370
|
-
|
|
371
188
|
</html>
|
|
372
189
|
|
|
373
190
|
```
|
|
374
191
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
|
375
192
|
initが初期表示のサーブレット
|
|
376
|
-
insertが空白判定と追加の処理
|
|
377
193
|
jspが画面表示用です。
|
|
378
194
|
|
|
379
195
|
|
7
文法修正
title
CHANGED
|
@@ -1,1 +1,1 @@
|
|
|
1
|
-
javaで
|
|
1
|
+
javaで部署管理
|
body
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
###前提・実現したいこと
|
|
2
2
|
プログラミング、java共に初心者です。
|
|
3
|
-
|
|
3
|
+
授業で部署の管理システムというものを作っており、
|
|
4
|
-
|
|
4
|
+
画面でコードと部署名を入力し、
|
|
5
|
-
登録ボタンを押すと
|
|
5
|
+
登録ボタンを押すとコードと部署名の追加と変更を行う、
|
|
6
|
-
空白のまま登録ボタンを押すと
|
|
6
|
+
空白のまま登録ボタンを押すと登録できないシステムを作ろうとしています。
|
|
7
7
|
|
|
8
8
|
###発生している問題・エラーメッセージ
|
|
9
|
-
|
|
9
|
+
Initを実行すると、初期表示はされるのですが、何も入力せずに登録ボタンを押す、
|
|
10
10
|
また部署コード、部署名を入力し追加ボタンを押してもHTTPステータス404(The requested resource is not available.) が表示されエラーになってしまう状態です。
|
|
11
11
|
|
|
12
12
|
まだjavaのことを理解しておらず、どこのソースがどのように動いているのかすら全て把握していないため、余分な部分も
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
###該当のソースコード(
|
|
20
|
+
###該当のソースコード(init)
|
|
21
21
|
```lang-言語名
|
|
22
22
|
package seminar;
|
|
23
23
|
|
|
@@ -34,22 +34,22 @@
|
|
|
34
34
|
import javax.servlet.http.HttpServletRequest;
|
|
35
35
|
import javax.servlet.http.HttpServletResponse;
|
|
36
36
|
|
|
37
|
-
public class
|
|
37
|
+
public class init extends HttpServlet {
|
|
38
38
|
private static final long serialVersionUID = 1L;
|
|
39
39
|
|
|
40
|
-
public
|
|
40
|
+
public init() {
|
|
41
41
|
super();
|
|
42
42
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
|
46
46
|
throws ServletException, IOException {
|
|
47
|
-
String driver =
|
|
47
|
+
//String driver =
|
|
48
|
-
String url =
|
|
48
|
+
//String url =
|
|
49
|
-
String user = "postgres";
|
|
49
|
+
//String user = "postgres";
|
|
50
50
|
//String pwd =
|
|
51
51
|
|
|
52
|
-
String
|
|
52
|
+
String sql = "Select * from DEPT order by d_no";
|
|
53
53
|
Connection conn = null;
|
|
54
54
|
|
|
55
55
|
request.setCharacterEncoding("UTF-8");
|
|
@@ -61,24 +61,24 @@
|
|
|
61
61
|
Class.forName(driver);
|
|
62
62
|
conn = DriverManager.getConnection(url, user, pwd);
|
|
63
63
|
Statement stmt = conn.createStatement();
|
|
64
|
-
ResultSet rs = stmt.executeQuery(
|
|
64
|
+
ResultSet rs = stmt.executeQuery(sql);
|
|
65
65
|
|
|
66
|
-
ArrayList<
|
|
66
|
+
ArrayList<Dept> dept_list = new ArrayList<Dept>();
|
|
67
67
|
while (rs.next()) {
|
|
68
|
-
String dept_no = rs.getString("
|
|
68
|
+
String dept_no = rs.getString("D_NO");
|
|
69
|
-
String dept_name = rs.getString("
|
|
69
|
+
String dept_name = rs.getString("D_NAME");
|
|
70
70
|
|
|
71
71
|
//
|
|
72
|
-
|
|
72
|
+
Dept bean = new Dept();
|
|
73
|
-
bean.
|
|
73
|
+
bean.setDno(d_no);
|
|
74
|
-
bean.
|
|
74
|
+
bean.setDname(d_name);
|
|
75
75
|
//
|
|
76
|
-
|
|
76
|
+
d_list.add(bean);
|
|
77
77
|
}
|
|
78
78
|
//
|
|
79
79
|
|
|
80
|
-
request.setAttribute("depts",
|
|
80
|
+
request.setAttribute("depts", d_list);
|
|
81
|
-
RequestDispatcher rd = request.getRequestDispatcher("
|
|
81
|
+
RequestDispatcher rd = request.getRequestDispatcher("03.jsp");
|
|
82
82
|
rd.forward(request, response);
|
|
83
83
|
|
|
84
84
|
} catch (Exception ex) {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
|
-
###該当のソースコード(
|
|
106
|
+
###該当のソースコード(Insert)
|
|
107
107
|
```lang-言語名
|
|
108
108
|
package seminar;
|
|
109
109
|
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
import javax.servlet.http.HttpServletRequest;
|
|
118
118
|
import javax.servlet.http.HttpServletResponse;
|
|
119
119
|
|
|
120
|
-
public class
|
|
120
|
+
public class Insert extends HttpServlet {
|
|
121
121
|
private static final long serialVersionUID = 1L;
|
|
122
122
|
|
|
123
|
-
public
|
|
123
|
+
public Insert() {
|
|
124
124
|
super();
|
|
125
125
|
|
|
126
126
|
}
|
|
@@ -129,38 +129,38 @@
|
|
|
129
129
|
throws ServletException, IOException {
|
|
130
130
|
|
|
131
131
|
Connection conn = null;
|
|
132
|
-
String sql = "insert into (
|
|
132
|
+
String sql = "insert into (D_NO,D_NAME)values(?, ?)";
|
|
133
133
|
|
|
134
134
|
try {
|
|
135
135
|
if (request.getCharacterEncoding() == null) {
|
|
136
136
|
request.setCharacterEncoding("UTF-8");
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
String
|
|
139
|
+
String pm_no = request.getParameter("fg");
|
|
140
|
-
String
|
|
140
|
+
String pm_name = request.getParameter("dname");
|
|
141
|
-
String tourokuFlag = request.getParameter("
|
|
141
|
+
String tourokuFlag = request.getParameter("fg");
|
|
142
142
|
|
|
143
|
-
DeptBean bean = new
|
|
143
|
+
DeptBean bean = new Dept();
|
|
144
|
-
bean.setDeptno(
|
|
144
|
+
bean.setDeptno(p_no);
|
|
145
|
-
bean.
|
|
145
|
+
bean.setDname(p_name);
|
|
146
146
|
|
|
147
147
|
boolean is_error = false;
|
|
148
148
|
|
|
149
|
-
if (
|
|
149
|
+
if (Fg != null) {
|
|
150
150
|
|
|
151
|
-
if (bean.
|
|
151
|
+
if (bean.getDno() == null ||
|
|
152
|
-
bean.
|
|
152
|
+
bean.getDname() == null ||
|
|
153
|
-
bean.
|
|
153
|
+
bean.getDno().trim().equals("")||
|
|
154
|
-
bean.
|
|
154
|
+
bean.getDname().trim().equals("")
|
|
155
155
|
) {
|
|
156
156
|
is_error = true;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
request.setAttribute("dept", bean);
|
|
160
160
|
|
|
161
|
-
String
|
|
161
|
+
String jsp = "03.jsp";
|
|
162
162
|
if (is_error) {
|
|
163
|
-
|
|
163
|
+
jsp = "03.jsp";
|
|
164
164
|
request.setAttribute("err_msg", "データが全て入力されていません");
|
|
165
165
|
}
|
|
166
166
|
RequestDispatcher rd = request.getRequestDispatcher(jsp_page);
|
|
@@ -170,20 +170,20 @@
|
|
|
170
170
|
|
|
171
171
|
conn = Uty.getConnection();
|
|
172
172
|
PreparedStatement ppst = conn.prepareStatement(sql);
|
|
173
|
-
ppst.setString(1,bean.
|
|
173
|
+
ppst.setString(1,bean.getDno());
|
|
174
|
-
ppst.setString(2,bean.
|
|
174
|
+
ppst.setString(2,bean.getDname());
|
|
175
175
|
int count = ppst.executeUpdate();
|
|
176
176
|
conn.close();
|
|
177
177
|
|
|
178
|
-
String msg = "
|
|
178
|
+
String msg = "完了しました";
|
|
179
179
|
if(count < 1){
|
|
180
|
-
msg = "
|
|
180
|
+
msg = "エラー";
|
|
181
181
|
|
|
182
182
|
}
|
|
183
183
|
request.setAttribute("dept",bean);
|
|
184
184
|
request.setAttribute("err_msg",msg);
|
|
185
185
|
|
|
186
|
-
RequestDispatcher rd = request.getRequestDispatcher("
|
|
186
|
+
RequestDispatcher rd = request.getRequestDispatcher("03.jsp");
|
|
187
187
|
rd.forward(request,response);
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -209,34 +209,34 @@
|
|
|
209
209
|
|
|
210
210
|
}
|
|
211
211
|
```
|
|
212
|
-
###該当のソースコード(Class
|
|
212
|
+
###該当のソースコード(Class Dept)
|
|
213
213
|
```lang-言語名
|
|
214
|
-
package
|
|
214
|
+
package kanri;
|
|
215
215
|
|
|
216
|
-
public class
|
|
216
|
+
public class Dept{
|
|
217
217
|
|
|
218
218
|
|
|
219
|
-
private String
|
|
219
|
+
private String m_no = "";
|
|
220
220
|
|
|
221
221
|
public String getDeptno() {
|
|
222
|
-
return this.
|
|
222
|
+
return this.m_no;
|
|
223
223
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
public void setDeptno(String deptno) {
|
|
227
|
-
this.
|
|
227
|
+
this.m_no = dno;
|
|
228
228
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
private String m_dept_name = "";
|
|
232
232
|
|
|
233
|
-
public String
|
|
233
|
+
public String getDname() {
|
|
234
|
-
return this.
|
|
234
|
+
return this.m_name;
|
|
235
235
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
public void
|
|
238
|
+
public void setDname(String dname) {
|
|
239
|
-
this.
|
|
239
|
+
this.m_name = dname;
|
|
240
240
|
|
|
241
241
|
|
|
242
242
|
}
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
```
|
|
248
248
|
###該当のソースコード(class Uty)
|
|
249
249
|
```lang-言語名
|
|
250
|
-
package
|
|
250
|
+
package kanri;
|
|
251
251
|
|
|
252
252
|
import java.sql.Connection;
|
|
253
253
|
import java.sql.ResultSet;
|
|
@@ -268,20 +268,12 @@
|
|
|
268
268
|
return conn;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
|
|
272
|
-
bean.setEmpno(rs.getString("EMP_NO"));
|
|
273
|
-
bean.setDeptno(rs.getString("DEPT_NO"));
|
|
274
|
-
bean.setEmpname(rs.getString("EMP_NAME"));
|
|
275
|
-
bean.setEmpkana(rs.getString("EMP_KANA"));
|
|
276
|
-
bean.setAge(rs.getInt("AGE"));
|
|
277
|
-
bean.setGender(rs.getInt("GENDER"));
|
|
278
|
-
bean.setRemarks(rs.getString("REMARKS"));
|
|
279
|
-
}
|
|
280
272
|
|
|
281
|
-
public static void setDeptBeanFromRs(
|
|
273
|
+
public static void setDeptBeanFromRs(Deptbean,ResultSet rs) throws SQLException{
|
|
282
274
|
|
|
283
|
-
bean.setDeptno(rs.getString("
|
|
275
|
+
bean.setDeptno(rs.getString("NO"));
|
|
284
|
-
bean.setDeptname(rs.getString("
|
|
276
|
+
bean.setDeptname(rs.getString("NAME"));
|
|
285
277
|
|
|
286
278
|
}
|
|
287
279
|
}
|
|
@@ -295,7 +287,6 @@
|
|
|
295
287
|
pageEncoding="UTF-8"%>
|
|
296
288
|
|
|
297
289
|
<%@page import="java.util.ArrayList"%>
|
|
298
|
-
<%@page import="seminar.EmpBean"%>
|
|
299
290
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
|
300
291
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
|
301
292
|
|
|
@@ -304,17 +295,16 @@
|
|
|
304
295
|
<html>
|
|
305
296
|
<head>
|
|
306
297
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
307
|
-
<title>
|
|
298
|
+
<title>部署管理</title>
|
|
308
299
|
</head>
|
|
309
300
|
<body>
|
|
310
|
-
<form method="post" action="
|
|
301
|
+
<form method="post" action="insert">
|
|
311
|
-
<input type="hidden" name="
|
|
302
|
+
<input type="hidden" name="fg" value="true">
|
|
312
|
-
<div style="wideth:80%; padding:1px; background-color:lightskyblue;">
|
|
313
303
|
|
|
314
|
-
<h1>
|
|
304
|
+
<h1>部署管理</h1>
|
|
315
305
|
|
|
316
306
|
</div>
|
|
317
|
-
|
|
307
|
+
|
|
318
308
|
<center>
|
|
319
309
|
<table>
|
|
320
310
|
<tr>
|
|
@@ -322,13 +312,13 @@
|
|
|
322
312
|
<td>部署コード</td>
|
|
323
313
|
<td><input type="text" name="deptno" id = "textforscb3" ></td>
|
|
324
314
|
<td width = 30>
|
|
325
|
-
<td><button type="submit" name="
|
|
315
|
+
<td><button type="submit" name="fg"> 登 録</button></td>
|
|
326
316
|
</tr>
|
|
327
317
|
<tr>
|
|
328
318
|
<td>部署名</td>
|
|
329
|
-
<td> <input type="text" name="
|
|
319
|
+
<td> <input type="text" name="dname"></td>
|
|
330
320
|
<td width = 30>
|
|
331
|
-
<td><button type="submit"
|
|
321
|
+
<td><button type="submit" >変 更</button></td>
|
|
332
322
|
|
|
333
323
|
|
|
334
324
|
</tr>
|
|
@@ -338,16 +328,16 @@
|
|
|
338
328
|
<br>
|
|
339
329
|
|
|
340
330
|
|
|
341
|
-
<form method="post" action="
|
|
331
|
+
<form method="post" action="Init">
|
|
342
332
|
<center>
|
|
343
|
-
|
|
333
|
+
|
|
344
|
-
<table border=
|
|
334
|
+
<table border=1 height="300" width="350" bgcolor="#f5f5f5">
|
|
345
335
|
|
|
346
336
|
<tr bgcolor="#4169e1">
|
|
347
337
|
|
|
348
338
|
<th></th>
|
|
349
|
-
<th width="2">
|
|
339
|
+
<th width="2">コード</th>
|
|
350
|
-
<th width="30">部署
|
|
340
|
+
<th width="30">部署</th>
|
|
351
341
|
|
|
352
342
|
|
|
353
343
|
<c:forEach var="dept" items="${depts}">
|
|
@@ -358,8 +348,8 @@
|
|
|
358
348
|
|
|
359
349
|
|
|
360
350
|
|
|
361
|
-
<td>${dept.
|
|
351
|
+
<td>${dept.dno}</td>
|
|
362
|
-
<td>${dept.
|
|
352
|
+
<td>${dept.dname}</td>
|
|
363
353
|
|
|
364
354
|
</tr>
|
|
365
355
|
</c:forEach>
|
|
@@ -374,11 +364,7 @@
|
|
|
374
364
|
<br>
|
|
375
365
|
|
|
376
366
|
|
|
377
|
-
<DIV align="right" style="margin-right:160px">
|
|
378
|
-
<button type="submit" style="background-color:steelblue;;width:170px;height:30px;margin-right:150px;"><font color="#fffaf">削 除</font></button>
|
|
379
|
-
</Div>
|
|
380
367
|
|
|
381
|
-
|
|
382
368
|
</body>
|
|
383
369
|
|
|
384
370
|
|
|
@@ -386,24 +372,14 @@
|
|
|
386
372
|
|
|
387
373
|
```
|
|
388
374
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
|
389
|
-
|
|
375
|
+
initが初期表示のサーブレット
|
|
390
|
-
|
|
376
|
+
insertが空白判定と追加の処理
|
|
391
|
-
|
|
377
|
+
jspが画面表示用です。
|
|
392
378
|
|
|
393
|
-
開発環境はeclipse,サーバーはTomcat6を使用しています。
|
|
394
379
|
|
|
395
380
|
|
|
396
381
|
|
|
397
|
-
部署名と部署コードのデータはPostgreSQLでテーブルを作成し、その中にデータが入っており、
|
|
398
|
-
そのデータを引っ張ってきている形です。
|
|
399
|
-
テーブル情報は下記の通りです
|
|
400
382
|
|
|
401
|
-
テーブル名 : DEPT
|
|
402
|
-
|
|
403
|
-
カラム名 カラム名 定義
|
|
404
|
-
部署コード DEPT_NO CHAR(2) PK
|
|
405
|
-
部署名 DEPT_NAME VARCHAR(20)
|
|
406
|
-
|
|
407
383
|
javaのことがまだ全然理解できておらず、至らない点も多々ございます。
|
|
408
384
|
拙い説明で本当に申し訳ございませんが、宜しければどなたかご教授頂ければ幸いです。
|
|
409
385
|
宜しくお願い致します。
|
6
誤字
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
###前提・実現したいこと
|
|
2
|
-
java初心者です。
|
|
2
|
+
プログラミング、java共に初心者です。
|
|
3
3
|
課題で、従業員の管理システムというものを作っており、
|
|
4
4
|
部署メンテ画面で部署コードと部署名を入力し、
|
|
5
5
|
登録ボタンを押すと部署コードと部署名の追加と変更を行う、
|
5
誤字
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
|
-
###該当のソースコード(
|
|
106
|
+
###該当のソースコード(MyServlet_busyo_insert)
|
|
107
107
|
```lang-言語名
|
|
108
108
|
package seminar;
|
|
109
109
|
|
4
誤字
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
|
|
289
289
|
```
|
|
290
290
|
|
|
291
|
-
###該当のソースコード(
|
|
291
|
+
###該当のソースコード(JSP)
|
|
292
292
|
```lang-言語名
|
|
293
293
|
|
|
294
294
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
3
書式の改善
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
###該当のソースコード(My_Servlet_busyo_init)
|
|
21
|
-
|
|
21
|
+
```lang-言語名
|
|
22
22
|
package seminar;
|
|
23
23
|
|
|
24
24
|
import java.io.IOException;
|
|
@@ -102,9 +102,9 @@
|
|
|
102
102
|
doGet(request, response);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
```
|
|
106
106
|
###該当のソースコード(MySerblet_busyo_insert)
|
|
107
|
-
|
|
107
|
+
```lang-言語名
|
|
108
108
|
package seminar;
|
|
109
109
|
|
|
110
110
|
import java.io.IOException;
|
|
@@ -208,8 +208,9 @@
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
```
|
|
212
212
|
###該当のソースコード(Class DeptBean)
|
|
213
|
+
```lang-言語名
|
|
213
214
|
package seminar;
|
|
214
215
|
|
|
215
216
|
public class DeptBean{
|
|
@@ -243,8 +244,9 @@
|
|
|
243
244
|
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
|
|
247
|
+
```
|
|
247
248
|
###該当のソースコード(class Uty)
|
|
249
|
+
```lang-言語名
|
|
248
250
|
package seminar;
|
|
249
251
|
|
|
250
252
|
import java.sql.Connection;
|
|
@@ -284,9 +286,105 @@
|
|
|
284
286
|
}
|
|
285
287
|
}
|
|
286
288
|
|
|
289
|
+
```
|
|
287
290
|
|
|
291
|
+
###該当のソースコード(class Uty)
|
|
292
|
+
```lang-言語名
|
|
288
293
|
|
|
294
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
|
295
|
+
pageEncoding="UTF-8"%>
|
|
289
296
|
|
|
297
|
+
<%@page import="java.util.ArrayList"%>
|
|
298
|
+
<%@page import="seminar.EmpBean"%>
|
|
299
|
+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
|
300
|
+
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
304
|
+
<html>
|
|
305
|
+
<head>
|
|
306
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
307
|
+
<title>社員情報管理システム</title>
|
|
308
|
+
</head>
|
|
309
|
+
<body>
|
|
310
|
+
<form method="post" action="MyServlet_busyo_insert">
|
|
311
|
+
<input type="hidden" name="touroku" value="true">
|
|
312
|
+
<div style="wideth:80%; padding:1px; background-color:lightskyblue;">
|
|
313
|
+
|
|
314
|
+
<h1>社員情報管理システム:部署メンテ画面</h1>
|
|
315
|
+
|
|
316
|
+
</div>
|
|
317
|
+
<br><br>
|
|
318
|
+
<center>
|
|
319
|
+
<table>
|
|
320
|
+
<tr>
|
|
321
|
+
|
|
322
|
+
<td>部署コード</td>
|
|
323
|
+
<td><input type="text" name="deptno" id = "textforscb3" ></td>
|
|
324
|
+
<td width = 30>
|
|
325
|
+
<td><button type="submit" name="touroku" style="background-color:steelblue;;width:170px;height:30px"><font color="#fffaf"> 登 録</font></button></td>
|
|
326
|
+
</tr>
|
|
327
|
+
<tr>
|
|
328
|
+
<td>部署名</td>
|
|
329
|
+
<td> <input type="text" name="deptname"></td>
|
|
330
|
+
<td width = 30>
|
|
331
|
+
<td><button type="submit" style="background-color:steelblue;;width:170px;height:30px"><font color="#fffaf">変 更</font></button></td>
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
</tr>
|
|
335
|
+
</table>
|
|
336
|
+
</center>
|
|
337
|
+
</form>
|
|
338
|
+
<br>
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
<form method="post" action="MyServlet_busyo_init">
|
|
342
|
+
<center>
|
|
343
|
+
<div style="height: 290px; width: 400px; overflow-y: scroll;">
|
|
344
|
+
<table border=0 height="300" width="350" bgcolor="#f5f5f5">
|
|
345
|
+
|
|
346
|
+
<tr bgcolor="#4169e1">
|
|
347
|
+
|
|
348
|
+
<th></th>
|
|
349
|
+
<th width="2">部署コード</th>
|
|
350
|
+
<th width="30">部署名</th>
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
<c:forEach var="dept" items="${depts}">
|
|
354
|
+
<tr>
|
|
355
|
+
<td style = "width:3px">
|
|
356
|
+
<input type="checkbox" class="ck" onclick="connecttext('textforscb3',this.checked);" /></td>
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
<td>${dept.deptno}</td>
|
|
362
|
+
<td>${dept.deptname}</td>
|
|
363
|
+
|
|
364
|
+
</tr>
|
|
365
|
+
</c:forEach>
|
|
366
|
+
|
|
367
|
+
</table>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
</center>
|
|
371
|
+
</form>
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
<br>
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
<DIV align="right" style="margin-right:160px">
|
|
378
|
+
<button type="submit" style="background-color:steelblue;;width:170px;height:30px;margin-right:150px;"><font color="#fffaf">削 除</font></button>
|
|
379
|
+
</Div>
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
</body>
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
</html>
|
|
386
|
+
|
|
387
|
+
```
|
|
290
388
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
|
291
389
|
MyServlet_initが初期表示のサーブレット(ポスグレからデータを引っ張ってきて表示)
|
|
292
390
|
MyServlet_insertが空白判定と追加の処理
|
2
誤字
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
###該当のソースコード
|
|
21
|
-
My_Servlet_busyo_init
|
|
20
|
+
###該当のソースコード(My_Servlet_busyo_init)
|
|
22
21
|
|
|
23
22
|
package seminar;
|
|
24
23
|
|
|
@@ -104,10 +103,8 @@
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
###該当のソースコード
|
|
106
|
+
###該当のソースコード(MySerblet_busyo_insert)
|
|
108
107
|
|
|
109
|
-
//MyServlet_busyo_insert
|
|
110
|
-
|
|
111
108
|
package seminar;
|
|
112
109
|
|
|
113
110
|
import java.io.IOException;
|
|
@@ -212,7 +209,7 @@
|
|
|
212
209
|
|
|
213
210
|
}
|
|
214
211
|
|
|
215
|
-
###該当のソースコード
|
|
212
|
+
###該当のソースコード(Class DeptBean)
|
|
216
213
|
package seminar;
|
|
217
214
|
|
|
218
215
|
public class DeptBean{
|
|
@@ -247,7 +244,7 @@
|
|
|
247
244
|
}
|
|
248
245
|
|
|
249
246
|
|
|
250
|
-
###該当のソースコード
|
|
247
|
+
###該当のソースコード(class Uty)
|
|
251
248
|
package seminar;
|
|
252
249
|
|
|
253
250
|
import java.sql.Connection;
|
|
@@ -309,6 +306,6 @@
|
|
|
309
306
|
部署コード DEPT_NO CHAR(2) PK
|
|
310
307
|
部署名 DEPT_NAME VARCHAR(20)
|
|
311
308
|
|
|
312
|
-
|
|
309
|
+
javaのことがまだ全然理解できておらず、至らない点も多々ございます。
|
|
313
310
|
拙い説明で本当に申し訳ございませんが、宜しければどなたかご教授頂ければ幸いです。
|
|
314
311
|
宜しくお願い致します。
|
1
補足情報を入力し忘れましたすみません…
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -13,12 +13,10 @@
|
|
|
13
13
|
多々混ざっているかもしれません。
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
MyServlet_initが初期表示のサーブレット(ポスグレからデータを引っ張ってきて表示)
|
|
17
|
-
MyServlet_insertが空白判定と追加の処理
|
|
18
|
-
jsp03が画面表示用です。
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
|
|
19
|
+
|
|
22
20
|
###該当のソースコード
|
|
23
21
|
My_Servlet_busyo_init
|
|
24
22
|
|
|
@@ -291,11 +289,26 @@
|
|
|
291
289
|
|
|
292
290
|
|
|
293
291
|
|
|
294
|
-
ここにご自身が実行したソースコードを書いてください
|
|
295
|
-
```
|
|
296
292
|
|
|
297
|
-
###
|
|
293
|
+
###補足情報(言語/FW/ツール等のバージョンなど)
|
|
294
|
+
MyServlet_initが初期表示のサーブレット(ポスグレからデータを引っ張ってきて表示)
|
|
298
|
-
|
|
295
|
+
MyServlet_insertが空白判定と追加の処理
|
|
296
|
+
jsp03が画面表示用です。
|
|
299
297
|
|
|
298
|
+
開発環境はeclipse,サーバーはTomcat6を使用しています。
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
300
|
-
|
|
302
|
+
部署名と部署コードのデータはPostgreSQLでテーブルを作成し、その中にデータが入っており、
|
|
303
|
+
そのデータを引っ張ってきている形です。
|
|
304
|
+
テーブル情報は下記の通りです
|
|
305
|
+
|
|
306
|
+
テーブル名 : DEPT
|
|
307
|
+
|
|
308
|
+
カラム名 カラム名 定義
|
|
309
|
+
部署コード DEPT_NO CHAR(2) PK
|
|
310
|
+
部署名 DEPT_NAME VARCHAR(20)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
拙い説明で本当に申し訳ございませんが、宜しければどなたかご教授頂ければ幸いです。
|
|
301
|
-
|
|
314
|
+
宜しくお願い致します。
|