質問編集履歴

1

ご教授いただいたコードを追記した結果について

2019/12/03 14:07

投稿

katuobusi
katuobusi

スコア8

test CHANGED
File without changes
test CHANGED
@@ -218,6 +218,130 @@
218
218
 
219
219
 
220
220
 
221
+ ■2019/12/3 追記
222
+
223
+ 「file.delete();」の後へ下記のコードを追記したところ、コンパイルエラーが表示されました。
224
+
225
+
226
+
227
+ ・追記コード
228
+
229
+ http_session.setAttribute("language", map.get("X-Am-Language"));
230
+
231
+ String lang = "ja_JP";
232
+
233
+ } else {
234
+
235
+ String lang = "en_US";
236
+
237
+ }
238
+
239
+
240
+
241
+ Cookie cookie=new Cookie("localeKey",lang);
242
+
243
+ Cookie.setDomain("Webアプリサーバドメイン");
244
+
245
+ response.addCookie(cookie);
246
+
247
+ res.sendRedirect("WebアプリURL");
248
+
249
+
250
+
251
+ ・コンパイルエラー
252
+
253
+ AuthCheck.java:46: inconvertible types
254
+
255
+ found : boolean
256
+
257
+ required: java.lang.String
258
+
259
+ if ((String)http_session.getAttribute("X-Am-Language").equals("ja")) {
260
+
261
+ ^
262
+
263
+ AuthCheck.java:52: cookie is already defined in doFilter(javax.servlet.ServletRequest,javax.servlet.ServletResponse,javax.servlet.FilterChain)
264
+
265
+ Cookie cookie=new Cookie("localeKey",lang);
266
+
267
+ ^
268
+
269
+ AuthCheck.java:52: cannot find symbol
270
+
271
+ symbol : variable lang
272
+
273
+ location: class AuthCheck
274
+
275
+ Cookie cookie=new Cookie("localeKey",lang);
276
+
277
+ ^
278
+
279
+ AuthCheck.java:53: non-static method setDomain(java.lang.String) cannot be referenced from a static context
280
+
281
+ Cookie.setDomain("Webアプリサーバドメイン");
282
+
283
+ ^
284
+
285
+ AuthCheck.java:54: cannot find symbol
286
+
287
+ symbol : method addCookie(javax.servlet.http.Cookie)
288
+
289
+ location: interface javax.servlet.ServletResponse
290
+
291
+ response.addCookie(cookie);
292
+
293
+ ^
294
+
295
+ AuthCheck.java:65: inconvertible types
296
+
297
+ found : boolean
298
+
299
+ required: java.lang.String
300
+
301
+ if ((String)http_session.getAttribute("X-Am-Language").equals("ja")) {
302
+
303
+ ^
304
+
305
+ AuthCheck.java:71: cookie is already defined in doFilter(javax.servlet.ServletRequest,javax.servlet.ServletResponse,javax.servlet.FilterChain)
306
+
307
+ Cookie cookie=new Cookie("localeKey",lang);
308
+
309
+ ^
310
+
311
+ AuthCheck.java:71: cannot find symbol
312
+
313
+ symbol : variable lang
314
+
315
+ location: class AuthCheck
316
+
317
+ Cookie cookie=new Cookie("localeKey",lang);
318
+
319
+ ^
320
+
321
+ AuthCheck.java:72: non-static method setDomain(java.lang.String) cannot be referenced from a static context
322
+
323
+ Cookie.setDomain("Webアプリサーバドメイン");
324
+
325
+ ^
326
+
327
+ AuthCheck.java:73: cannot find symbol
328
+
329
+ symbol : method addCookie(javax.servlet.http.Cookie)
330
+
331
+ location: interface javax.servlet.ServletResponse
332
+
333
+ response.addCookie(cookie);
334
+
335
+ ^
336
+
337
+ Note: AuthCheck.java uses unchecked or unsafe operations.
338
+
339
+ Note: Recompile with -Xlint:unchecked for details.
340
+
341
+ 10 errors
342
+
343
+
344
+
221
345
  ### 補足情報(FW/ツールのバージョンなど)
222
346
 
223
347
  Websphere application server ND v.7.0