tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Cannot read httpservlet's inputstream
Date Tue, 07 Apr 2009 20:56:02 GMT
André Warnier wrote:
> Mark Thomas wrote:
>> André Warnier wrote:
>>> Despite what you may wish and what you may have found in Google, I
>>> believe that if you want to send a file, you have to do it with a
>>> "multipart/form-data" content type.
>>
>> Nope. That is just plain wrong.
>>
>>> http://www.faqs.org/rfcs/rfc2616.html
>>> Sections 9.5 (POST) and 9.6 (PUT) describe the two methods that allow
>>> you to upload a file.  But 9.6 is not applicable, since you are sending
>>> this to a webapp, not directly to a URI.
>>
>> Wrong again. PUT is disabled by default for security reasons but it is
>> valid and is supported by the default servlet.
>>
> Ok Mark, I don't pretend I know how it works in Tomcat.
> How does one upload a file then ?
> 
> I mean other than with a PUT, as I presume that the OP doesn't just want
> to write files arbitrarily in his URI space on the server)

Put the content in the body of a POST, read the request body content in
your servlet and do whatever you need to do with it. If you want to add
extra attributes and send them via POST then you'll need to use
"multipart/form-data". At that point using a library will be easier than
coding it yourself although you can if you want. There are other ways of
sending extra attributes that don't use multipart.

There are, as usual, many ways of doing this and no one way is the best.
It will depend on what you are trying to do and why.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message