質問編集履歴

7

修正

2018/05/13 02:57

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -14,25 +14,65 @@
14
14
 
15
15
  //eclipseのコンソールのエラー内容
16
16
 
17
- 情報: サービス [Catalina] を起動します [日 5月 13 10:42:33 JST 2018]
18
-
19
- 情報: Starting Servlet Engine: Apache Tomcat/9.0.7 [日 5月 13 10:42:33 JST 2018]
20
-
21
- 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [日 5月 13 10:42:34 JST 2018]
22
-
23
- 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [日 5月 13 10:42:34 JST 2018]
24
-
25
- 情報: Starting ProtocolHandler ["http-nio-8080"] [日 5月 13 10:42:34 JST 2018]
26
-
27
- 情報: Starting ProtocolHandler ["ajp-nio-8009"] [日 5月 13 10:42:34 JST 2018]
28
-
29
- 情報: Server startup in 934 ms [日 5月 13 10:42:34 JST 2018]
30
-
31
- 重大: サーブレット [sample.SampleServlet] のServlet.service()が例外を投げました [日 5月 13 10:42:41 JST 2018]
32
-
33
- 重大: サーブレット [sample.SampleServlet] のServlet.service()が例外を投げました [日 5月 13 10:55:20 JST 2018]
34
-
35
- 重大: サーブレット [sample.SampleServlet] のServlet.service()が例外を投げました [日 5月 13 11:15:22 JST 2018]
17
+ 情報: Server version: Apache Tomcat/9.0.7 [日 5月 13 11:53:50 JST 2018]
18
+
19
+ 情報: Server built: Apr 3 2018 19:53:05 UTC [日 5月 13 11:53:50 JST 2018]
20
+
21
+ 情報: Server number: 9.0.7.0 [日 5月 13 11:53:50 JST 2018]
22
+
23
+ 情報: OS Name: Windows 10 [日 5月 13 11:53:50 JST 2018]
24
+
25
+ 情報: OS Version: 10.0 [日 5月 13 11:53:50 JST 2018]
26
+
27
+ 情報: Architecture: amd64 [日 5月 13 11:53:50 JST 2018]
28
+
29
+ 情報: Java Home: C:\pleiades\pleiades\java\10 [日 5月 13 11:53:50 JST 2018]
30
+
31
+ 情報: JVM Version: 10+46 [日 5月 13 11:53:50 JST 2018]
32
+
33
+ 情報: JVM Vendor: "Oracle Corporation" [日 5月 13 11:53:50 JST 2018]
34
+
35
+ 情報: CATALINA_BASE: C:\pleiades\pleiades\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1 [日 5月 13 11:53:50 JST 2018]
36
+
37
+ 情報: CATALINA_HOME: C:\pleiades\pleiades\tomcat\9 [日 5月 13 11:53:50 JST 2018]
38
+
39
+ 情報: Command line argument: -Dcatalina.base=C:\pleiades\pleiades\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1 [日 5月 13 11:53:50 JST 2018]
40
+
41
+ 情報: Command line argument: -Dcatalina.home=C:\pleiades\pleiades\tomcat\9 [日 5月 13 11:53:50 JST 2018]
42
+
43
+ 情報: Command line argument: -Dwtp.deploy=C:\pleiades\pleiades\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps [日 5月 13 11:53:50 JST 2018]
44
+
45
+ 情報: Command line argument: -Dfile.encoding=UTF-8 [日 5月 13 11:53:50 JST 2018]
46
+
47
+ 情報: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\pleiades\pleiades\java\10\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/pleiades/pleiades/eclipse/jre/bin/../jre/bin/server;C:/pleiades/pleiades/eclipse/jre/bin/../jre/bin;C:/pleiades/pleiades/eclipse/jre/bin/../jre/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;c:\Program Files\java\jdk-10.0.1\bin;"C:\Program Files\Java\jdk-10.0.1\bin;";C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Users\nakamura\AppData\Local\Microsoft\WindowsApps;;C:\pleiades\pleiades\eclipse;;.] [日 5月 13 11:53:50 JST 2018]
48
+
49
+ 情報: Initializing ProtocolHandler ["http-nio-8080"] [日 5月 13 11:53:50 JST 2018]
50
+
51
+ 情報: Using a shared selector for servlet write/read [日 5月 13 11:53:50 JST 2018]
52
+
53
+ 情報: Initializing ProtocolHandler ["ajp-nio-8009"] [日 5月 13 11:53:50 JST 2018]
54
+
55
+ 情報: Using a shared selector for servlet write/read [日 5月 13 11:53:50 JST 2018]
56
+
57
+ 情報: Initialization processed in 935 ms [日 5月 13 11:53:50 JST 2018]
58
+
59
+ 情報: サービス [Catalina] を起動します [日 5月 13 11:53:50 JST 2018]
60
+
61
+ 情報: Starting Servlet Engine: Apache Tomcat/9.0.7 [日 5月 13 11:53:50 JST 2018]
62
+
63
+ 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [日 5月 13 11:53:51 JST 2018]
64
+
65
+ 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [日 5月 13 11:53:51 JST 2018]
66
+
67
+ 情報: Starting ProtocolHandler ["http-nio-8080"] [日 5月 13 11:53:51 JST 2018]
68
+
69
+ 情報: Starting ProtocolHandler ["ajp-nio-8009"] [日 5月 13 11:53:51 JST 2018]
70
+
71
+ 情報: Server startup in 872 ms [日 5月 13 11:53:51 JST 2018]
72
+
73
+ 重大: サーブレット [sample.FileUpload] のServlet.service()が例外を投げました [日 5月 13 11:54:00 JST 2018]
74
+
75
+
36
76
 
37
77
  //内部ブラウザhttp://localhost:8080/SampleServlet/sampleのエラー
38
78
 

6

編集

2018/05/13 02:57

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- プロジェクトファイル名FileUploadでsample.htmlを実行するとエラーになる。
1
+ プロジェクトファイル名SampleServletでsample.htmlを実行するとエラーになる。
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  eclipseで実行しています。
4
4
 
5
- 動的プロジェクトファイル名FileUploadでsample.htmlを実行すると
5
+ 動的プロジェクトファイル名SampleServletでsample.htmlを実行すると
6
6
 
7
7
  ダイアログが出て、
8
8
 
@@ -12,43 +12,89 @@
12
12
 
13
13
  エラーが出ます。
14
14
 
15
- //エラー内容
16
-
17
- 情報: Initialization processed in 814 ms [ 5月 12 21:38:24 JST 2018]
18
-
19
- 情報: サービス [Catalina] を起動します [ 5月 12 21:38:24 JST 2018]
20
-
21
- 情報: Starting Servlet Engine: Apache Tomcat/9.0.7 [ 5月 12 21:38:24 JST 2018]
22
-
23
- 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [ 5月 12 21:38:24 JST 2018]
24
-
25
- 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [ 5月 12 21:38:25 JST 2018]
26
-
27
- 情報: Starting ProtocolHandler ["http-nio-8080"] [ 5月 12 21:38:25 JST 2018]
28
-
29
- 情報: Starting ProtocolHandler ["ajp-nio-8009"] [ 5月 12 21:38:25 JST 2018]
30
-
31
- 情報: Server startup in 729 ms [ 5月 12 21:38:25 JST 2018]
32
-
33
- 重大: サーブレット [sample.Servlet3] のServlet.service()が例外を投げました [ 5月 12 21:39:28 JST 2018]
34
-
35
- 重大: サーブレット [sample.Servlet3] のServlet.service()が例外を投げました [ 5月 12 21:41:16 JST 2018]
36
-
37
- 重大: サーブレット [sample.Servlet3] のServlet.service()が例外を投げました [土 5月 12 21:45:57 JST 2018]
38
-
39
- 重大: サブレット [sample.Servlet3] Servlet.service()が例外を投げました [土 5月 12 21:57:27 JST 2018]
40
-
41
-
42
-
43
- どこが悪いのか教えてください。
44
-
45
-
46
-
47
- 送信されたファイルはサーバーに保存したいのですが。どこにそれは書いてあるのですか。
48
-
49
- Tomcatのwebappsのwar_b.warにおくられるのですか。
50
-
51
- eclipseのServersの中に書いてあるのですか。
15
+ //eclipseのコンソールのエラー内容
16
+
17
+ 情報: サービス [Catalina] を起動します [ 5月 13 10:42:33 JST 2018]
18
+
19
+ 情報: Starting Servlet Engine: Apache Tomcat/9.0.7 [ 5月 13 10:42:33 JST 2018]
20
+
21
+ 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [ 5月 13 10:42:34 JST 2018]
22
+
23
+ 情報: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [ 5月 13 10:42:34 JST 2018]
24
+
25
+ 情報: Starting ProtocolHandler ["http-nio-8080"] [ 5月 13 10:42:34 JST 2018]
26
+
27
+ 情報: Starting ProtocolHandler ["ajp-nio-8009"] [ 5月 13 10:42:34 JST 2018]
28
+
29
+ 情報: Server startup in 934 ms [ 5月 13 10:42:34 JST 2018]
30
+
31
+ 重大: サーブレット [sample.SampleServlet] のServlet.service()が例外を投げました [ 5月 13 10:42:41 JST 2018]
32
+
33
+ 重大: サーブレット [sample.SampleServlet] のServlet.service()が例外を投げました [ 5月 13 10:55:20 JST 2018]
34
+
35
+ 重大: サーブレット [sample.SampleServlet] のServlet.service()が例外を投げました [ 5月 13 11:15:22 JST 2018]
36
+
37
+ //内部ブラウザhttp://localhost:8080/SampleServlet/sampleのエラー
38
+
39
+ HTTPステタス 500 - Internal Server Error
40
+
41
+ Type Exception Report
42
+
43
+ メッセージ Unable to process parts as no multi-part configuration has been provided
44
+
45
+
46
+
47
+ 説明 The server encountered an unexpected condition that prevented it from fulfilling the request.
48
+
49
+
50
+
51
+ 例外
52
+
53
+ java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
54
+
55
+ org.apache.catalina.connector.Request.parseParts(Request.java:2746)
56
+
57
+ org.apache.catalina.connector.Request.getParts(Request.java:2712)
58
+
59
+ org.apache.catalina.connector.Request.getPart(Request.java:2875)
60
+
61
+ org.apache.catalina.connector.RequestFacade.getPart(RequestFacade.java:1105)
62
+
63
+ sample.SampleServlet.doPost(SampleServlet.java:31)
64
+
65
+ javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
66
+
67
+ javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
68
+
69
+ org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
70
+
71
+ 注意 原因のすべてのスタックトレースは、のログに記録されています
72
+
73
+ Apache Tomcat/9.0.7
74
+
75
+ 以上です。
76
+
77
+ SampleServletをeclipseで単独で実行しても以下のエラーになります。
78
+
79
+ 内部ブラウザhttp://localhost:8080/SampleServlet/sampleに
80
+
81
+ HTTPステータス 405 - Method Not Allowed
82
+
83
+ Type ステータスレポート
84
+
85
+
86
+
87
+ メッセージ HTTPのGETメソッドは、このURLではサポートされていません。
88
+
89
+
90
+
91
+ 説明 The method received in the request-line is known by the origin server but not supported by the target resource.
92
+
93
+ Apache Tomcat/9.0.7
94
+
95
+
96
+
97
+
52
98
 
53
99
  よろしくお願いいたします。
54
100
 

5

修正

2018/05/13 02:24

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -90,19 +90,17 @@
90
90
 
91
91
 
92
92
 
93
- //FileUpload/src/sample/Servlet3.java
93
+ //SampleServlet/src/sample/SampleServlet.java
94
94
 
95
95
  package sample;
96
96
 
97
97
 
98
98
 
99
- import java.io.BufferedInputStream;
100
-
101
- import java.io.FileInputStream;
102
-
103
99
  import java.io.IOException;
104
100
 
105
- import java.io.OutputStream;
101
+ import java.io.PrintWriter;
102
+
103
+ import java.util.Date;
106
104
 
107
105
 
108
106
 
@@ -118,17 +116,19 @@
118
116
 
119
117
  import javax.servlet.http.HttpServletResponse;
120
118
 
119
+ import javax.servlet.http.Part;
120
+
121
121
 
122
122
 
123
123
  @WebServlet("/sample")
124
124
 
125
- public class Servlet3 extends HttpServlet {
125
+ public class SampleServlet extends HttpServlet {
126
126
 
127
127
  private static final long serialVersionUID = 1L;
128
128
 
129
129
 
130
130
 
131
- public Servlet3() {
131
+ public SampleServlet() {
132
132
 
133
133
  super();
134
134
 
@@ -152,58 +152,38 @@
152
152
 
153
153
  ServletContext con = this.getServletContext();
154
154
 
155
- response.setContentType("application/octet-stream");
156
-
157
- OutputStream ops = response.getOutputStream();
158
-
159
- request.setCharacterEncoding("UTF-8");
160
-
161
- String fname = request.getParameter("fname");
155
+ Part part = request.getPart("fname");
156
+
162
-
157
+ String fname = "FILE" + new Date().getTime() + ".data";
158
+
163
- response.setHeader("Content-Disposition", "attachment; filename="
159
+ String disposition = part.getHeader("Content-Disposition");
164
-
165
- + fname);
160
+
166
-
167
- fname = con.getRealPath("/WEB-INF/" + fname);
161
+ String[] headers = disposition.split(";");
168
-
169
- // 出力処理
162
+
170
-
171
- FileInputStream fis = null;
172
-
173
- BufferedInputStream bis = null;
163
+ for (String header : headers) {
174
-
175
- try {
164
+
176
-
177
- fis = new FileInputStream(fname);
165
+ String str = header.trim();
166
+
178
-
167
+ if (str.startsWith("filename=")) {
168
+
179
- bis = new BufferedInputStream(fis);
169
+ str = str.substring(10, str.length() - 1);
180
-
170
+
181
- int n = -1;
171
+ String[] paths = str.split("\\");
182
-
172
+
183
- while ((n = bis.read()) != -1) {
173
+ fname = paths[paths.length - 1];
184
-
185
- ops.write(n);
186
174
 
187
175
  }
188
176
 
189
- } catch (IOException ex) {
190
-
191
- // 特になにもしない
192
-
193
- } finally {
194
-
195
- try {
196
-
197
- bis.close();
198
-
199
- } catch (IOException ex) {
200
-
201
- // 特になにもしない
202
-
203
- }
204
-
205
177
  }
206
178
 
179
+ part.write(fname);
180
+
181
+ response.setContentType("text/html;charset=utf-8");
182
+
183
+ PrintWriter out = response.getWriter();
184
+
185
+ out.print("<html><body><h1>アップロードしました。</h1></body></html>");
186
+
207
187
  }
208
188
 
209
189
 
@@ -226,6 +206,4 @@
226
206
 
227
207
 
228
208
 
229
-
230
-
231
209
  ```

4

修正

2018/05/13 01:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,11 @@
4
4
 
5
5
  動的プロジェクトファイル名FileUploadでsample.htmlを実行すると
6
6
 
7
+ ダイアログが出て、
8
+
9
+ タイトル「ファイルのアップロード」
10
+
7
- ダイアログが出て、参照ボタンでファイル(c:\tmp\abcd.txt)を選択して送信すると
11
+ その下に「参照ボタン」クリック、ファイル選択でファイル(c:\tmp\abcd.txt)を選択して送信すると
8
12
 
9
13
  エラーが出ます。
10
14
 

3

修正

2018/05/13 01:09

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -42,6 +42,8 @@
42
42
 
43
43
  送信されたファイルはサーバーに保存したいのですが。どこにそれは書いてあるのですか。
44
44
 
45
+ Tomcatのwebappsのwar_b.warにおくられるのですか。
46
+
45
47
  eclipseのServersの中に書いてあるのですか。
46
48
 
47
49
  よろしくお願いいたします。

2

質問の修正

2018/05/13 00:06

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,8 +1,14 @@
1
1
  Eclipseを勉強中です。
2
2
 
3
+ eclipseで実行しています。
4
+
3
5
  動的プロジェクトファイル名FileUploadでsample.htmlを実行すると
4
6
 
5
- ダイアログが出て、参照ボタンでファイルを選択して送信すると
7
+ ダイアログが出て、参照ボタンでファイル(c:\tmp\abcd.txt)を選択して送信すると
8
+
9
+ エラーが出ます。
10
+
11
+ //エラー内容
6
12
 
7
13
  情報: Initialization processed in 814 ms [土 5月 12 21:38:24 JST 2018]
8
14
 
@@ -28,9 +34,15 @@
28
34
 
29
35
  重大: サーブレット [sample.Servlet3] のServlet.service()が例外を投げました [土 5月 12 21:57:27 JST 2018]
30
36
 
31
- のエラーが出ます。
37
+
32
-
38
+
33
- どこが悪いのか教えてください
39
+ どこが悪いのか教えてください
40
+
41
+
42
+
43
+ 送信されたファイルはサーバーに保存したいのですが。どこにそれは書いてあるのですか。
44
+
45
+ eclipseのServersの中に書いてあるのですか。
34
46
 
35
47
  よろしくお願いいたします。
36
48
 

1

質問の修正

2018/05/13 00:00

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  のエラーが出ます。
32
32
 
33
-
33
+ どこが悪いのか教えてください
34
34
 
35
35
  よろしくお願いいたします。
36
36