|
Prev: china nike shoes sale at www.shoeshive.net whole sale ordan collection shoes
Next: Non-verbose, simple way of getting pixels of an image?
From: dhtml on 14 Jul 2008 13:08 Can't get my multipart/form-data processed. Error: "Stream ended unexpectedly" The post body is sent over XMLHttpRequest. (the submission works fine if sent via "normal" form submission). There seems to be a problem with the request. Bad headers, or content-length incorrect? I can't spot the error. Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java: 515) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java: 408) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java: 320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) com.jspinsider.jspkit.gzip.GZIPFilter.doFilter(Unknown Source) </pre></p><p><b>root cause</b> <pre>javax.servlet.ServletException: org.apache.commons.fileupload.FileUploadException : Processing of multipart/form-data request failed. Stream ended unexpectedly ^^^^^^^^^^^^^^^^^^^^^^^^^^^ page /ape/release/example/form/process.jsp at line 10 7: // Create a new file upload handler 8: ServletFileUpload upload = new ServletFileUpload(factory); 9: 10: List<FileItem> items = upload.parseRequest(request); 11: response.setContentType("text/plain"); 12: out.write(items.toString()); 13: Is an incorrect content-length causing this? Here is the first request, via XMLHttpRequest form submission: ---------------------------------------------------------- http://localhost/ape/release/example/form/process.jsp POST /ape/release/example/form/process.jsp HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv: 1.9) Gecko/2008061004 Firefox/3.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Content-Type: multipart/form-data; charset=UTF-8; boundary=DATA1215979532633 Referer: http://localhost/ape/release/example/form/Form.html Content-Length: 91 Cookie: JSESSIONID=242B477B4C9455A201CF1BF7D5CFCE16 Pragma: no-cache Cache-Control: no-cache --DATA1215979532633 Content-Disposition: form-data; name="name"; a --DATA1215979532633-- HTTP/1.x 500 Internal Server Error Server: Apache-Coyote/1.1 Content-Type: text/html;charset=utf-8 Content-Length: 3840 Date: Sun, 13 Jul 2008 20:05:32 GMT Connection: close ---------------------------------------------------------- Here is the second request, via "normal" form submission: ---------------------------------------------------------- http://localhost/ape/release/example/form/process.jsp POST /ape/release/example/form/process.jsp HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv: 1.9) Gecko/2008061004 Firefox/3.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://localhost/ape/release/example/form/Form.html Cookie: JSESSIONID=242B477B4C9455A201CF1BF7D5CFCE16 Content-Type: multipart/form-data; boundary=---------------------------1055457295855832845137158309 Content-Length: 170 -----------------------------1055457295855832845137158309 Content-Disposition: form-data; name="name" a -----------------------------1055457295855832845137158309-- HTTP/1.x 200 OK Server: Apache-Coyote/1.1 Content-Encoding: gzip Content-Type: text/plain Transfer-Encoding: chunked Date: Sun, 13 Jul 2008 20:10:15 GMT ---------------------------------------------------------- The java code: // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(request); response.setContentType("text/plain"); out.write(items.toString()); |