I’m writing a servlet that receives an xml file from the client and works with it.
My problem is, that in the servletinputstream (which i get with: request.getInputStream()) is some upload information at the beginning and at the end:
-----------------------------186292285129788
Content-Disposition: form-data; name="myFile"; filename="TASKDATA - Kopie.XML"
Content-Type: text/xml
<XML-Content>
-----------------------------186292285129788--
Is there a smart solution to cut those lines away from the servletinputstream?
greetings
That’s a
multipart/form-dataheader (as specified in RFC2388). Grab a fullworthymultipart/form-dataparser rather than reinventing your own. Apache Commons FileUpload is the defacto standard API for the job. Drop the required JAR files in/WEB-INF/liband then it’ll be as easy as:Once again, don’t reinvent your own. You really don’t want to have a maintenance aftermath.