質問編集履歴

2

質問を伏せるための質問修正であったため、復元いたしました。

2020/05/25 08:31

投稿

Aya_nishimura
Aya_nishimura

スコア16

test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,309 @@
1
1
  以下のコードを実行すると
2
2
 
3
+ 「 The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.」
4
+
3
5
  というエラーが発生します。
4
6
 
5
7
  おそらく、どこかのパスが違う気がするのですが、全くわかりません。
6
8
 
7
9
  どこが違うのかご教授お願いします。
10
+
11
+ ディレクトリ
12
+
13
+ ![イメージ説明](54d2ab35b2b1c47f7baba8e07d2b2a9d.png)
14
+
15
+ Health.java
16
+
17
+ ```ここに言語を入力
18
+
19
+ package model;
20
+
21
+ import java.io.Serializable;
22
+
23
+ public class Health implements Serializable {
24
+
25
+ private double height, weight, bmi;
26
+
27
+ private String bodyType;
28
+
29
+ public double getHeight() {
30
+
31
+ return height;
32
+
33
+ }
34
+
35
+ public void setHeight(Double height) {
36
+
37
+ this.height = height;
38
+
39
+ }
40
+
41
+ public double getWeight() {
42
+
43
+ return weight;
44
+
45
+ }
46
+
47
+ public void setWeight(Double weight) {
48
+
49
+ this.weight = weight;
50
+
51
+ }
52
+
53
+ public void setBmi(Double bmi) {
54
+
55
+ this.bmi = bmi;
56
+
57
+ }
58
+
59
+ public double getBmi() {
60
+
61
+ return this.bmi;
62
+
63
+ }
64
+
65
+ public void setBodyType(String bodyType) {
66
+
67
+ this.bodyType = bodyType;
68
+
69
+ }
70
+
71
+ public String getBodyType() {
72
+
73
+ return this.bodyType;
74
+
75
+ }
76
+
77
+ }
78
+
79
+ ```
80
+
81
+ healthCheck.java
82
+
83
+ ```ここに言語を入力
84
+
85
+ package servlet;
86
+
87
+ import java.io.IOException;
88
+
89
+ import javax.servlet.RequestDispatcher;
90
+
91
+ import javax.servlet.ServletException;
92
+
93
+ import javax.servlet.annotation.WebServlet;
94
+
95
+ import javax.servlet.http.HttpServlet;
96
+
97
+ import javax.servlet.http.HttpServletRequest;
98
+
99
+ import javax.servlet.http.HttpServletResponse;
100
+
101
+ import model.Health;
102
+
103
+ import model.HealthCheckLogic;
104
+
105
+ @WebServlet("/healthCheck")
106
+
107
+ public class HealthCheck extends HttpServlet {
108
+
109
+ private static final long serialVersionUID = 1L;
110
+
111
+ protected void doGet(HttpServletRequest request,
112
+
113
+ HttpServletResponse response)
114
+
115
+ throws ServletException, IOException {
116
+
117
+ // フォワード
118
+
119
+ RequestDispatcher dispatcher =
120
+
121
+ request.getRequestDispatcher
122
+
123
+ ("/WEB-INF/jsp/healthCheck.jsp");
124
+
125
+ dispatcher.forward(request, response);
126
+
127
+ }
128
+
129
+ protected void doPost(HttpServletRequest request,
130
+
131
+ HttpServletResponse response)
132
+
133
+ throws ServletException, IOException {
134
+
135
+ // リクエストパラメータを取得
136
+
137
+ String weight = request.getParameter("weight"); // 体重
138
+
139
+ String height = request.getParameter("height"); // 身長
140
+
141
+ // 入力値をプロパティに設定
142
+
143
+ Health health = new Health();
144
+
145
+ health.setHeight(Double.parseDouble(height));
146
+
147
+ health.setWeight(Double.parseDouble(weight));
148
+
149
+ // 健康診断を実行し結果を設定
150
+
151
+ HealthCheckLogic healthCheckLogic = new HealthCheckLogic();
152
+
153
+ healthCheckLogic.execute(health);
154
+
155
+ // リクエストスコープに保存
156
+
157
+ request.setAttribute("health", health);
158
+
159
+ // フォワード
160
+
161
+ RequestDispatcher dispatcher =
162
+
163
+ request.getRequestDispatcher
164
+
165
+ ("/jsp/healthCheckResult.jsp");
166
+
167
+ dispatcher.forward(request, response);
168
+
169
+ }
170
+
171
+ }
172
+
173
+ ```
174
+
175
+ healthCheck.jsp
176
+
177
+ ```ここに言語を入力
178
+
179
+ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
180
+
181
+ <!DOCTYPE html>
182
+
183
+ <html>
184
+
185
+ <head>
186
+
187
+ <meta charset="UTF-8">
188
+
189
+ <title>スッキリ健康診断</title>
190
+
191
+ </head>
192
+
193
+ <body>
194
+
195
+ <h1>スッキリ健康診断</h1>
196
+
197
+ <form action= "HealthCheck" method="post">
198
+
199
+ 身長:<input type="text" name="height">(cm)<br>
200
+
201
+ 体重:<input type="text" name="weight">(kg)<br>
202
+
203
+ <input type="submit" value="診断">
204
+
205
+ </form>
206
+
207
+ </body>
208
+
209
+ </html>
210
+
211
+ ```
212
+
213
+ HealthCheckLogic.java
214
+
215
+ ```ここに言語を入力
216
+
217
+ package model;
218
+
219
+ public class HealthCheckLogic {
220
+
221
+ public void execute(Health health) {
222
+
223
+ // BMIを算出して設定
224
+
225
+ double weight = health.getWeight();
226
+
227
+ double height = health.getHeight();
228
+
229
+ double bmi = weight / (height / 100.0 * height / 100.0);
230
+
231
+ health.setBmi(bmi);
232
+
233
+ // BMI指数から体格を判定して設定
234
+
235
+ String bodyType;
236
+
237
+ if (bmi < 18.5) {
238
+
239
+ bodyType = "痩せ型";
240
+
241
+ } else if (bmi < 25) {
242
+
243
+ bodyType = "普通";
244
+
245
+ } else {
246
+
247
+ bodyType = "肥満";
248
+
249
+ }
250
+
251
+ health.setBodyType(bodyType);
252
+
253
+ }
254
+
255
+ }
256
+
257
+ ```
258
+
259
+ healthCheckResult.java
260
+
261
+ ```ここに言語を入力
262
+
263
+ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
264
+
265
+ <%@ page import="model.Health" %>
266
+
267
+ <%
268
+
269
+ // リクエストスコープに保存されたHealthを取得
270
+
271
+ Health health = (Health) request.getAttribute("health");
272
+
273
+ %>
274
+
275
+ <!DOCTYPE html>
276
+
277
+ <html>
278
+
279
+ <head>
280
+
281
+ <meta charset="UTF-8">
282
+
283
+ <title>スッキリ健康診断</title>
284
+
285
+ </head>
286
+
287
+ <body>
288
+
289
+ <h1>スッキリ健康診断の結果</h1>
290
+
291
+ <p>
292
+
293
+ 身長:<%= health.getHeight() %><br>
294
+
295
+ 体重:<%= health.getWeight() %><br>
296
+
297
+ BMI:<%= health.getBmi() %><br>
298
+
299
+ 体格:<%= health.getBodyType() %>
300
+
301
+ </p>
302
+
303
+ <a href="/HealthCheck">戻る</a>
304
+
305
+ </body>
306
+
307
+ </html>
308
+
309
+ ```

1

ああああああ

2020/05/25 08:31

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Javaのブレット「The origin server did not find a current representation for the target resource or is n
1
+ Javaのエラについてす。高校の授業で。
test CHANGED
@@ -1,361 +1,7 @@
1
1
  以下のコードを実行すると
2
-
3
- 「 The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.」
4
2
 
5
3
  というエラーが発生します。
6
4
 
7
5
  おそらく、どこかのパスが違う気がするのですが、全くわかりません。
8
6
 
9
7
  どこが違うのかご教授お願いします。
10
-
11
-
12
-
13
- ディレクトリ
14
-
15
- ![イメージ説明](54d2ab35b2b1c47f7baba8e07d2b2a9d.png)
16
-
17
-
18
-
19
- Health.java
20
-
21
- ```ここに言語を入力
22
-
23
- package model;
24
-
25
-
26
-
27
- import java.io.Serializable;
28
-
29
-
30
-
31
- public class Health implements Serializable {
32
-
33
- private double height, weight, bmi;
34
-
35
- private String bodyType;
36
-
37
-
38
-
39
- public double getHeight() {
40
-
41
- return height;
42
-
43
- }
44
-
45
-
46
-
47
- public void setHeight(Double height) {
48
-
49
- this.height = height;
50
-
51
- }
52
-
53
-
54
-
55
- public double getWeight() {
56
-
57
- return weight;
58
-
59
- }
60
-
61
-
62
-
63
- public void setWeight(Double weight) {
64
-
65
- this.weight = weight;
66
-
67
- }
68
-
69
-
70
-
71
- public void setBmi(Double bmi) {
72
-
73
- this.bmi = bmi;
74
-
75
- }
76
-
77
-
78
-
79
- public double getBmi() {
80
-
81
- return this.bmi;
82
-
83
- }
84
-
85
-
86
-
87
- public void setBodyType(String bodyType) {
88
-
89
- this.bodyType = bodyType;
90
-
91
- }
92
-
93
-
94
-
95
- public String getBodyType() {
96
-
97
- return this.bodyType;
98
-
99
- }
100
-
101
- }
102
-
103
- ```
104
-
105
- healthCheck.java
106
-
107
- ```ここに言語を入力
108
-
109
- package servlet;
110
-
111
-
112
-
113
- import java.io.IOException;
114
-
115
-
116
-
117
- import javax.servlet.RequestDispatcher;
118
-
119
- import javax.servlet.ServletException;
120
-
121
- import javax.servlet.annotation.WebServlet;
122
-
123
- import javax.servlet.http.HttpServlet;
124
-
125
- import javax.servlet.http.HttpServletRequest;
126
-
127
- import javax.servlet.http.HttpServletResponse;
128
-
129
-
130
-
131
- import model.Health;
132
-
133
- import model.HealthCheckLogic;
134
-
135
-
136
-
137
- @WebServlet("/healthCheck")
138
-
139
- public class HealthCheck extends HttpServlet {
140
-
141
- private static final long serialVersionUID = 1L;
142
-
143
-
144
-
145
- protected void doGet(HttpServletRequest request,
146
-
147
- HttpServletResponse response)
148
-
149
- throws ServletException, IOException {
150
-
151
-
152
-
153
- // フォワード
154
-
155
- RequestDispatcher dispatcher =
156
-
157
- request.getRequestDispatcher
158
-
159
- ("/WEB-INF/jsp/healthCheck.jsp");
160
-
161
- dispatcher.forward(request, response);
162
-
163
- }
164
-
165
-
166
-
167
- protected void doPost(HttpServletRequest request,
168
-
169
- HttpServletResponse response)
170
-
171
- throws ServletException, IOException {
172
-
173
-
174
-
175
- // リクエストパラメータを取得
176
-
177
- String weight = request.getParameter("weight"); // 体重
178
-
179
- String height = request.getParameter("height"); // 身長
180
-
181
-
182
-
183
- // 入力値をプロパティに設定
184
-
185
- Health health = new Health();
186
-
187
- health.setHeight(Double.parseDouble(height));
188
-
189
- health.setWeight(Double.parseDouble(weight));
190
-
191
- // 健康診断を実行し結果を設定
192
-
193
- HealthCheckLogic healthCheckLogic = new HealthCheckLogic();
194
-
195
- healthCheckLogic.execute(health);
196
-
197
-
198
-
199
- // リクエストスコープに保存
200
-
201
- request.setAttribute("health", health);
202
-
203
-
204
-
205
- // フォワード
206
-
207
- RequestDispatcher dispatcher =
208
-
209
- request.getRequestDispatcher
210
-
211
- ("/jsp/healthCheckResult.jsp");
212
-
213
- dispatcher.forward(request, response);
214
-
215
- }
216
-
217
- }
218
-
219
-
220
-
221
- ```
222
-
223
- healthCheck.jsp
224
-
225
- ```ここに言語を入力
226
-
227
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
228
-
229
- <!DOCTYPE html>
230
-
231
- <html>
232
-
233
- <head>
234
-
235
- <meta charset="UTF-8">
236
-
237
- <title>スッキリ健康診断</title>
238
-
239
- </head>
240
-
241
- <body>
242
-
243
- <h1>スッキリ健康診断</h1>
244
-
245
- <form action= "HealthCheck" method="post">
246
-
247
- 身長:<input type="text" name="height">(cm)<br>
248
-
249
- 体重:<input type="text" name="weight">(kg)<br>
250
-
251
- <input type="submit" value="診断">
252
-
253
- </form>
254
-
255
- </body>
256
-
257
- </html>
258
-
259
- ```
260
-
261
- HealthCheckLogic.java
262
-
263
- ```ここに言語を入力
264
-
265
- package model;
266
-
267
-
268
-
269
- public class HealthCheckLogic {
270
-
271
- public void execute(Health health) {
272
-
273
- // BMIを算出して設定
274
-
275
- double weight = health.getWeight();
276
-
277
- double height = health.getHeight();
278
-
279
- double bmi = weight / (height / 100.0 * height / 100.0);
280
-
281
- health.setBmi(bmi);
282
-
283
-
284
-
285
- // BMI指数から体格を判定して設定
286
-
287
- String bodyType;
288
-
289
- if (bmi < 18.5) {
290
-
291
- bodyType = "痩せ型";
292
-
293
- } else if (bmi < 25) {
294
-
295
- bodyType = "普通";
296
-
297
- } else {
298
-
299
- bodyType = "肥満";
300
-
301
- }
302
-
303
- health.setBodyType(bodyType);
304
-
305
- }
306
-
307
- }
308
-
309
- ```
310
-
311
- healthCheckResult.java
312
-
313
- ```ここに言語を入力
314
-
315
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
316
-
317
- <%@ page import="model.Health" %>
318
-
319
- <%
320
-
321
- // リクエストスコープに保存されたHealthを取得
322
-
323
- Health health = (Health) request.getAttribute("health");
324
-
325
- %>
326
-
327
- <!DOCTYPE html>
328
-
329
- <html>
330
-
331
- <head>
332
-
333
- <meta charset="UTF-8">
334
-
335
- <title>スッキリ健康診断</title>
336
-
337
- </head>
338
-
339
- <body>
340
-
341
- <h1>スッキリ健康診断の結果</h1>
342
-
343
- <p>
344
-
345
- 身長:<%= health.getHeight() %><br>
346
-
347
- 体重:<%= health.getWeight() %><br>
348
-
349
- BMI:<%= health.getBmi() %><br>
350
-
351
- 体格:<%= health.getBodyType() %>
352
-
353
- </p>
354
-
355
- <a href="/HealthCheck">戻る</a>
356
-
357
- </body>
358
-
359
- </html>
360
-
361
- ```