質問編集履歴

13

ソースの編集

2017/01/24 06:24

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -98,6 +98,8 @@
98
98
 
99
99
 
100
100
 
101
+ ```
102
+
101
103
  ``````JSP
102
104
 
103
105
  <h1>${param.name}の編集</h1>

12

ソースの編集 内容の編集

2017/01/24 06:24

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,27 @@
1
+ ◆追記 1/24
2
+
3
+ UpdateUserCheck を作成しました。
4
+
5
+
6
+
7
+ ページを離れた事の判定ですが、
8
+
9
+ 現在は、ListServletに戻った時点で、mapからremoveする処理を追加しました。
10
+
11
+
12
+
13
+ 恐らく、これで対応できると思いますが、
14
+
15
+ 一点、編集中の画面をブラウザの閉じるボタンを実施したときの対応について悩んでおります。
16
+
17
+
18
+
19
+ 引き続き、知恵を貸していただけないでしょうか。
20
+
21
+ よろしくお願いします。
22
+
23
+
24
+
1
25
  ◆追記 1/23
2
26
 
3
27
  Mapを利用した、ソースを書いてみました。UpdateUserCheck_N
@@ -38,8 +62,6 @@
38
62
 
39
63
  ログイン後に既存ページを更新中に、別のユーザーから更新ページにアクセスがあった場合に、更新ページに入らせない。
40
64
 
41
-
42
-
43
65
  ユーザーIDはsessionで保持。
44
66
 
45
67
  一覧ページから編集したい項目の名前を押して、編集を押すと、パラメータをUsercheckServletに渡し、同一ユーザーかチェックし、同一ユーザーであれば、更新ページ(update.jsp)に飛ぶという流れにしようと思っています。
@@ -58,7 +80,7 @@
58
80
 
59
81
 
60
82
 
61
- ```jsp
83
+ ```ここに言語を入力
62
84
 
63
85
  <h1>${wikiPage.name}</h1>
64
86
 
@@ -72,6 +94,36 @@
72
94
 
73
95
  </c:if>
74
96
 
97
+
98
+
99
+
100
+
101
+ ``````JSP
102
+
103
+ <h1>${param.name}の編集</h1>
104
+
105
+ <form action="/wiki/update">
106
+
107
+ <input type="hidden" name="cmd" value="update">
108
+
109
+ <input type="hidden" name="name" value="${param.name}">
110
+
111
+ <textarea rows="15" cols="60" name="content">${param.content}</textarea>
112
+
113
+ ※200文字以内
114
+
115
+ <br>
116
+
117
+ <input type="submit" value="更新ˆ">
118
+
119
+ <input type="submit" value="削除" onclick="cmd.value='delete'">
120
+
121
+ <input type="button" value="キャンセル" onclick="location.href='list?name=${param.name}&id=${param.id}'">
122
+
123
+ </form>
124
+
125
+
126
+
75
127
  ```
76
128
 
77
129
  ```Servlet
@@ -82,6 +134,10 @@
82
134
 
83
135
  import java.io.IOException;
84
136
 
137
+ import java.util.List;
138
+
139
+ import java.util.Map;
140
+
85
141
 
86
142
 
87
143
  import javax.servlet.ServletContext;
@@ -94,6 +150,122 @@
94
150
 
95
151
  import javax.servlet.http.HttpServletResponse;
96
152
 
153
+
154
+
155
+ public class ListServlet extends HttpServlet {
156
+
157
+
158
+
159
+ @Override
160
+
161
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
162
+
163
+ throws ServletException, IOException {
164
+
165
+
166
+
167
+ ServletContext sc = getServletContext(); // アプリケーションスコープの取得
168
+
169
+ String name = request.getParameter("name");
170
+
171
+
172
+
173
+ /* リストページアクセス時に編集ページにアクセスの履歴があれば、処理を実施 */
174
+
175
+ if (sc.getAttribute("tmpMap") != null) {
176
+
177
+ int id = 0;
178
+
179
+ if (request.getParameter("id") == null || request.getParameter("id").isEmpty()) {
180
+
181
+ id = -1;
182
+
183
+ } else {
184
+
185
+ id = Integer.parseInt(request.getParameter("id"));
186
+
187
+ }
188
+
189
+
190
+
191
+ Map<String, Integer> map = autoCast(sc.getAttribute("tmpMap"));
192
+
193
+ if (map.containsKey(name)) {
194
+
195
+ if (map.get(name) == id) {
196
+
197
+ map.remove(name);
198
+
199
+ sc.setAttribute("tmpMap", map);
200
+
201
+ }
202
+
203
+ }
204
+
205
+ }
206
+
207
+
208
+
209
+ try {
210
+
211
+ List<WikiBean> list = WikiPageDAO.getInstance().findAll();
212
+
213
+ request.setAttribute("list", list);
214
+
215
+ } catch (Exception e) {
216
+
217
+ throw new ServletException(e);
218
+
219
+ }
220
+
221
+
222
+
223
+ request.getRequestDispatcher("/wikiView/list.jsp").forward(request, response);
224
+
225
+ }
226
+
227
+
228
+
229
+ /* 戻り値の型に合わせてキャスト */
230
+
231
+ @SuppressWarnings("unchecked")
232
+
233
+ public static <T> T autoCast(Object obj) {
234
+
235
+ T castedObject = (T) obj;
236
+
237
+ return castedObject;
238
+
239
+ }
240
+
241
+ }
242
+
243
+ ```
244
+
245
+
246
+
247
+ ```Servlet
248
+
249
+ package wiki;
250
+
251
+
252
+
253
+ import java.io.IOException;
254
+
255
+ import java.util.HashMap;
256
+
257
+
258
+
259
+ import javax.servlet.ServletContext;
260
+
261
+ import javax.servlet.ServletException;
262
+
263
+ import javax.servlet.http.HttpServlet;
264
+
265
+ import javax.servlet.http.HttpServletRequest;
266
+
267
+ import javax.servlet.http.HttpServletResponse;
268
+
97
269
  import javax.servlet.http.HttpSession;
98
270
 
99
271
 
@@ -114,208 +286,82 @@
114
286
 
115
287
 
116
288
 
117
- HttpSession session = request.getSession(true);
289
+ HttpSession session = request.getSession(false);
118
290
 
119
291
  ServletContext sc = getServletContext(); // アプリケーションスコープの取得
120
292
 
121
293
 
122
294
 
123
- WikiBean wiki = (WikiBean) session.getAttribute("wikiPage");
295
+ String name = request.getParameter("name"); // 編集中のページ名を取得
124
296
 
125
297
  AccountBean account = (AccountBean) session.getAttribute("account");
126
298
 
127
299
 
128
300
 
129
- /* 比較のため、アプリケーションスコープ変数がnullなら現在のログインIDとwikiの名前tmpにセット */
301
+ /* アプリケーションスコープがnullであれば、新しくMap取得する */
130
-
302
+
131
- int tmpId = 0;
303
+ HashMap<String, Integer> map = null;
132
-
304
+
133
- if (sc.getAttribute("tmpId") == null) {
305
+ if (sc.getAttribute("tmpMap") == null) {
306
+
134
-
307
+ map = new HashMap<String, Integer>();
308
+
309
+ } else {
310
+
135
- sc.setAttribute("tmpId", account.getId());
311
+ map = autoCast(sc.getAttribute("tmpMap")); // メソッドでキャスト
136
312
 
137
313
  }
138
314
 
139
- tmpId = Integer.parseInt(sc.getAttribute("tmpId").toString());
315
+
140
-
141
-
142
-
316
+
143
- String tmpName = null;
317
+ String message = null;
318
+
144
-
319
+ if (map.containsKey(name)) {
320
+
321
+ if (map.get(name) != account.getId()) {
322
+
323
+ message = "他のユーザーにて編集中です";
324
+
145
- if (sc.getAttribute("tmpName") == null) {
325
+ request.setAttribute("message", message);
326
+
146
-
327
+ request.getRequestDispatcher("list").forward(request, response);
328
+
329
+ } else {
330
+
331
+ map.put(name, account.getId());
332
+
147
- sc.setAttribute("tmpName", wiki.getName());
333
+ sc.setAttribute("tmpMap", map);
334
+
335
+ request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
336
+
337
+ }
338
+
339
+ } else {
340
+
341
+ map.put(name, account.getId());
342
+
343
+ sc.setAttribute("tmpMap", map);
344
+
345
+ request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
148
346
 
149
347
  }
150
348
 
151
- tmpName = sc.getAttribute("tmpName").toString();
152
-
153
-
154
-
155
- /* 同じユーザーかチェックし、異なれば編集中の旨を表示する */
156
-
157
- String message = null;
158
-
159
- if (tmpId != account.getId() && tmpName.equals(wiki.getName())) {
160
-
161
- message = "他のユーザーにて編集中です";
162
-
163
- request.setAttribute("message", message);
164
-
165
- request.setAttribute("name", wiki.getName());
166
-
167
- request.getRequestDispatcher("/list").forward(request, response);
168
-
169
- } else {
170
-
171
- request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
172
-
173
- }
174
-
175
349
  }
176
350
 
351
+
352
+
353
+ /* 戻り値の型に合わせてキャスト */
354
+
355
+ @SuppressWarnings("unchecked")
356
+
357
+ public static <T> T autoCast(Object obj) {
358
+
359
+ T castedObject = (T) obj;
360
+
361
+ return castedObject;
362
+
363
+ }
364
+
177
365
  }
178
366
 
179
367
  ```
180
-
181
-
182
-
183
- ```servlet
184
-
185
- package wiki;
186
-
187
-
188
-
189
- import java.io.IOException;
190
-
191
- import java.util.HashMap;
192
-
193
-
194
-
195
- import javax.servlet.ServletContext;
196
-
197
- import javax.servlet.ServletException;
198
-
199
- import javax.servlet.http.HttpServlet;
200
-
201
- import javax.servlet.http.HttpServletRequest;
202
-
203
- import javax.servlet.http.HttpServletResponse;
204
-
205
- import javax.servlet.http.HttpSession;
206
-
207
-
208
-
209
- import Account.AccountBean;
210
-
211
-
212
-
213
- public class UpdateUserCheck_N extends HttpServlet {
214
-
215
-
216
-
217
- @Override
218
-
219
- public synchronized void doGet(HttpServletRequest request, HttpServletResponse response)
220
-
221
- throws ServletException, IOException {
222
-
223
-
224
-
225
- HttpSession session = request.getSession(false);
226
-
227
- ServletContext sc = getServletContext(); // アプリケーションスコープの取得
228
-
229
-
230
-
231
- WikiBean wiki = (WikiBean) session.getAttribute("wikiPage");
232
-
233
- AccountBean account = (AccountBean) session.getAttribute("account");
234
-
235
-
236
-
237
- /* アプリケーションスコープがnullであれば、新しくMapを取得する */
238
-
239
- HashMap<String, Integer> map = null;
240
-
241
- if (sc.getAttribute("map") == null) {
242
-
243
- map = new HashMap<String, Integer>();
244
-
245
- map.put(wiki.getName(), account.getId());
246
-
247
- } else {
248
-
249
- map = (HashMap) sc.getAttribute("tmpMap");
250
-
251
- }
252
-
253
-
254
-
255
- String message = null;
256
-
257
- if (map.containsKey(wiki.getName())) {
258
-
259
- if (map.get(wiki.getName()) == account.getId()) {
260
-
261
- request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
262
-
263
- } else {
264
-
265
- message = "他のユーザーにて編集中です";
266
-
267
- request.setAttribute("message", message);
268
-
269
- request.setAttribute("name", wiki.getName());
270
-
271
- request.getRequestDispatcher("/list").forward(request, response);
272
-
273
- }
274
-
275
- } else {
276
-
277
- request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
278
-
279
- }
280
-
281
-
282
-
283
- sc.setAttribute("map", map); // アプリケーションスコープにセット
284
-
285
- }
286
-
287
- }
288
-
289
-
290
-
291
- ```
292
-
293
-
294
-
295
-
296
-
297
- ```jsp
298
-
299
- <h1>${param.name}の編集</h1>
300
-
301
- <form action="/wiki/update">
302
-
303
- <input type="hidden" name="cmd" value="update">
304
-
305
- <input type="hidden" name="name" value="${param.name}">
306
-
307
- <textarea rows="15" cols="60" name="content">${param.content}</textarea>
308
-
309
- ※200文字以内
310
-
311
- <br>
312
-
313
- <input type="submit" value="更新ˆ">
314
-
315
- <input type="submit" value="削除" onclick="cmd.value='delete'">
316
-
317
- <input type="button" value="キャンセル" onclick="location.href='/wiki/refer?name=${param.name}">
318
-
319
- </form>
320
-
321
- ```

11

ソースの追加

2017/01/24 06:21

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,17 @@
1
+ ◆追記 1/23
2
+
3
+ Mapを利用した、ソースを書いてみました。UpdateUserCheck_N
4
+
5
+ (まだ、動かしてません)
6
+
7
+
8
+
9
+ 引き続き、良い方法がないか知恵を貸していただきたいです。
10
+
11
+
12
+
13
+
14
+
1
15
  ◆追記
2
16
 
3
17
  UpdateUserCheckを編集しました。
@@ -16,8 +30,6 @@
16
30
 
17
31
 
18
32
 
19
-
20
-
21
33
  現在、ServletとJSPで掲示板を作成しています。
22
34
 
23
35
 
@@ -168,6 +180,118 @@
168
180
 
169
181
 
170
182
 
183
+ ```servlet
184
+
185
+ package wiki;
186
+
187
+
188
+
189
+ import java.io.IOException;
190
+
191
+ import java.util.HashMap;
192
+
193
+
194
+
195
+ import javax.servlet.ServletContext;
196
+
197
+ import javax.servlet.ServletException;
198
+
199
+ import javax.servlet.http.HttpServlet;
200
+
201
+ import javax.servlet.http.HttpServletRequest;
202
+
203
+ import javax.servlet.http.HttpServletResponse;
204
+
205
+ import javax.servlet.http.HttpSession;
206
+
207
+
208
+
209
+ import Account.AccountBean;
210
+
211
+
212
+
213
+ public class UpdateUserCheck_N extends HttpServlet {
214
+
215
+
216
+
217
+ @Override
218
+
219
+ public synchronized void doGet(HttpServletRequest request, HttpServletResponse response)
220
+
221
+ throws ServletException, IOException {
222
+
223
+
224
+
225
+ HttpSession session = request.getSession(false);
226
+
227
+ ServletContext sc = getServletContext(); // アプリケーションスコープの取得
228
+
229
+
230
+
231
+ WikiBean wiki = (WikiBean) session.getAttribute("wikiPage");
232
+
233
+ AccountBean account = (AccountBean) session.getAttribute("account");
234
+
235
+
236
+
237
+ /* アプリケーションスコープがnullであれば、新しくMapを取得する */
238
+
239
+ HashMap<String, Integer> map = null;
240
+
241
+ if (sc.getAttribute("map") == null) {
242
+
243
+ map = new HashMap<String, Integer>();
244
+
245
+ map.put(wiki.getName(), account.getId());
246
+
247
+ } else {
248
+
249
+ map = (HashMap) sc.getAttribute("tmpMap");
250
+
251
+ }
252
+
253
+
254
+
255
+ String message = null;
256
+
257
+ if (map.containsKey(wiki.getName())) {
258
+
259
+ if (map.get(wiki.getName()) == account.getId()) {
260
+
261
+ request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
262
+
263
+ } else {
264
+
265
+ message = "他のユーザーにて編集中です";
266
+
267
+ request.setAttribute("message", message);
268
+
269
+ request.setAttribute("name", wiki.getName());
270
+
271
+ request.getRequestDispatcher("/list").forward(request, response);
272
+
273
+ }
274
+
275
+ } else {
276
+
277
+ request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
278
+
279
+ }
280
+
281
+
282
+
283
+ sc.setAttribute("map", map); // アプリケーションスコープにセット
284
+
285
+ }
286
+
287
+ }
288
+
289
+
290
+
291
+ ```
292
+
293
+
294
+
171
295
 
172
296
 
173
297
  ```jsp

10

内容を修正

2017/01/23 08:09

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ◆追記
2
2
 
3
- UsercheckServletを編集しました。
3
+ UpdateUserCheckを編集しました。
4
4
 
5
5
  最初にページに入ったログインユーザIDとページネームをtmpに格納して、比較しようと考えています。
6
6
 

9

ソースを編集

2017/01/22 12:06

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -72,6 +72,8 @@
72
72
 
73
73
 
74
74
 
75
+ import javax.servlet.ServletContext;
76
+
75
77
  import javax.servlet.ServletException;
76
78
 
77
79
  import javax.servlet.http.HttpServlet;
@@ -80,55 +82,79 @@
80
82
 
81
83
  import javax.servlet.http.HttpServletResponse;
82
84
 
85
+ import javax.servlet.http.HttpSession;
86
+
87
+
88
+
89
+ import Account.AccountBean;
90
+
83
91
 
84
92
 
85
93
  public class UpdateUserCheck extends HttpServlet {
86
94
 
87
95
 
88
96
 
89
- private static int tmpId;
97
+ @Override
90
98
 
99
+ public synchronized void doGet(HttpServletRequest request, HttpServletResponse response)
100
+
91
- private static String tmpName;
101
+ throws ServletException, IOException {
92
102
 
93
103
 
94
104
 
95
- @Override
105
+ HttpSession session = request.getSession(true);
96
106
 
97
- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
107
+ ServletContext sc = getServletContext(); // アプリケーションスコープの取得
98
108
 
99
109
 
100
110
 
101
- System.out.println("22: " + tmpId);
111
+ WikiBean wiki = (WikiBean) session.getAttribute("wikiPage");
102
112
 
103
- System.out.println("23: " + tmpName);
113
+ AccountBean account = (AccountBean) session.getAttribute("account");
104
114
 
105
115
 
106
116
 
107
- int id = Integer.parseInt(request.getParameter("id").toString());
117
+ /* 比較のため、アプリケーションスコープ変数がnullなら現在のログインIDとwikiの名前をtmpにセット */
108
118
 
119
+ int tmpId = 0;
120
+
121
+ if (sc.getAttribute("tmpId") == null) {
122
+
123
+ sc.setAttribute("tmpId", account.getId());
124
+
125
+ }
126
+
109
- String name = request.getParameter("name");
127
+ tmpId = Integer.parseInt(sc.getAttribute("tmpId").toString());
110
128
 
111
129
 
112
130
 
131
+ String tmpName = null;
132
+
133
+ if (sc.getAttribute("tmpName") == null) {
134
+
135
+ sc.setAttribute("tmpName", wiki.getName());
136
+
137
+ }
138
+
139
+ tmpName = sc.getAttribute("tmpName").toString();
140
+
141
+
142
+
143
+ /* 同じユーザーかチェックし、異なれば編集中の旨を表示する */
144
+
113
145
  String message = null;
114
146
 
115
- if (tmpId != id && tmpName != null && tmpName.equals(name)) {
147
+ if (tmpId != account.getId() && tmpName.equals(wiki.getName())) {
116
148
 
117
149
  message = "他のユーザーにて編集中です";
118
150
 
119
151
  request.setAttribute("message", message);
120
152
 
121
- response.sendRedirect("/wiki/list");
153
+ request.setAttribute("name", wiki.getName());
154
+
155
+ request.getRequestDispatcher("/list").forward(request, response);
122
156
 
123
157
  } else {
124
-
125
- tmpId = id;
126
-
127
- tmpName = name;
128
-
129
- System.out.println("41: " + tmpId);
130
-
131
- System.out.println("42: " + tmpName);
132
158
 
133
159
  request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
134
160
 
@@ -148,7 +174,7 @@
148
174
 
149
175
  <h1>${param.name}の編集</h1>
150
176
 
151
- <form action="../update">
177
+ <form action="/wiki/update">
152
178
 
153
179
  <input type="hidden" name="cmd" value="update">
154
180
 
@@ -164,7 +190,7 @@
164
190
 
165
191
  <input type="submit" value="削除" onclick="cmd.value='delete'">
166
192
 
167
- <input type="button" value="キャンセル" onclick="location.href='../refer?name=${param.name}'">
193
+ <input type="button" value="キャンセル" onclick="location.href='/wiki/refer?name=${param.name}">
168
194
 
169
195
  </form>
170
196
 

8

ソースの編集

2017/01/22 11:56

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  <c:if test="${login == 'OK' && wikiPage.name != 'welcome'}">
58
58
 
59
- <a href="/wiki/UpdateUserCheck?name=${wikiPage.name}&content=${wikiPage.content}">このページを更新</a>
59
+ <a href="/wiki/UpdateUserCheck?id=${account.id}&name=${wikiPage.name}&content=${wikiPage.content}">このページを更新</a>
60
60
 
61
61
  </c:if>
62
62
 

7

内容を編集

2017/01/21 23:15

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
 
9
9
  途中の段階ですが、引き続き知恵を貸していただけないでしょうか。
10
+
11
+
10
12
 
11
13
  ------------------
12
14
 

6

内容を修正

2017/01/21 23:09

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ◆追記
1
+ ◆追記
2
2
 
3
3
  UsercheckServletを編集しました。
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  途中の段階ですが、引き続き知恵を貸していただけないでしょうか。
10
10
 
11
-
11
+ ------------------
12
12
 
13
13
 
14
14
 

5

ソースを編集

2017/01/21 23:08

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,21 @@
1
+ ◆追記
2
+
3
+ UsercheckServletを編集しました。
4
+
5
+ 最初にページに入ったログインユーザIDとページネームをtmpに格納して、比較しようと考えています。
6
+
7
+
8
+
9
+ 途中の段階ですが、引き続き知恵を貸していただけないでしょうか。
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
1
19
  現在、ServletとJSPで掲示板を作成しています。
2
20
 
3
21
 
@@ -50,6 +68,8 @@
50
68
 
51
69
  import java.io.IOException;
52
70
 
71
+
72
+
53
73
  import javax.servlet.ServletException;
54
74
 
55
75
  import javax.servlet.http.HttpServlet;
@@ -58,47 +78,41 @@
58
78
 
59
79
  import javax.servlet.http.HttpServletResponse;
60
80
 
61
- import javax.servlet.http.HttpSession;
62
-
63
81
 
64
82
 
65
83
  public class UpdateUserCheck extends HttpServlet {
66
84
 
67
85
 
68
86
 
69
- @Override
87
+ private static int tmpId;
70
88
 
71
- public synchronized void doGet(HttpServletRequest request, HttpServletResponse response)
72
-
73
- throws ServletException, IOException {
89
+ private static String tmpName;
74
90
 
75
91
 
76
92
 
93
+ @Override
94
+
77
- HttpSession session = request.getSession(true);
95
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
78
96
 
79
97
 
80
98
 
81
- String tmpName = request.getParameter("name");
99
+ System.out.println("22: " + tmpId);
82
100
 
83
- String tmpId = session.getAttribute("id").toString();
101
+ System.out.println("23: " + tmpName);
84
-
85
- String flg = "on";
86
102
 
87
103
 
88
104
 
89
- System.out.println(tmpId);
105
+ int id = Integer.parseInt(request.getParameter("id").toString());
90
106
 
91
- System.out.println(tmpName);
107
+ String name = request.getParameter("name");
92
108
 
93
109
 
94
110
 
95
111
  String message = null;
96
112
 
97
- if (flg.equals("on")) {
113
+ if (tmpId != id && tmpName != null && tmpName.equals(name)) {
98
114
 
99
- if (tmpId == session.getAttribute("id").toString() && tmpName == request.getParameter("name"))
100
-
101
- message = "他のユーザーにて編集中です";
115
+ message = "他のユーザーにて編集中です";
102
116
 
103
117
  request.setAttribute("message", message);
104
118
 
@@ -106,7 +120,15 @@
106
120
 
107
121
  } else {
108
122
 
123
+ tmpId = id;
124
+
125
+ tmpName = name;
126
+
127
+ System.out.println("41: " + tmpId);
128
+
129
+ System.out.println("42: " + tmpName);
130
+
109
- request.getRequestDispatcher("wikiView/update.jsp").forward(request, response);
131
+ request.getRequestDispatcher("/wikiView/update.jsp").forward(request, response);
110
132
 
111
133
  }
112
134
 

4

codeタブの修正

2017/01/21 23:08

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -61,8 +61,6 @@
61
61
  import javax.servlet.http.HttpSession;
62
62
 
63
63
 
64
-
65
- ```java Servlet
66
64
 
67
65
  public class UpdateUserCheck extends HttpServlet {
68
66
 

3

ソース部分の編集

2017/01/21 11:07

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -41,8 +41,6 @@
41
41
  </c:if>
42
42
 
43
43
  ```
44
-
45
-
46
44
 
47
45
  ```Servlet
48
46
 

2

内容の修正

2017/01/21 11:06

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -44,15 +44,13 @@
44
44
 
45
45
 
46
46
 
47
+ ```Servlet
48
+
47
49
  package wiki;
48
50
 
49
51
 
50
52
 
51
53
  import java.io.IOException;
52
-
53
-
54
-
55
- ```Servlet
56
54
 
57
55
  import javax.servlet.ServletException;
58
56
 
@@ -122,7 +120,7 @@
122
120
 
123
121
  ```
124
122
 
125
- ```
123
+
126
124
 
127
125
 
128
126
 

1

内容を修正

2017/01/21 11:04

投稿

n000n00
n000n00

スコア25

test CHANGED
File without changes
test CHANGED
@@ -51,6 +51,8 @@
51
51
  import java.io.IOException;
52
52
 
53
53
 
54
+
55
+ ```Servlet
54
56
 
55
57
  import javax.servlet.ServletException;
56
58
 
@@ -120,6 +122,8 @@
120
122
 
121
123
  ```
122
124
 
125
+ ```
126
+
123
127
 
124
128
 
125
129
  ```jsp