4

I have a task to implement sending of http multipart request and interpreting http multipart response. I decided to start from the response as I just have to receive a response and parse it. I have not that much experience with java and even less with HTTP and that is why I read some articles and other stuff on the topic but I have still some open questions:

  1. As far as I understood the content type multipart is used for file upload, sending email attachments, etc. The most posts that I found in google were actully for file upload using multipart/form-data. In what other cases is this content-type used?
  2. I decided to start with the HTTP multipart response, but I realised I have no idea what I have to do in order to receive a response with such a content type. How shall my request look like, what shall I request with this request? I just want to write a simple program in java, which sends an HTTP request to a server and the response that is received is with content-type multipart.

It would be nice if someone can clarify these things to me because I think I have misunderstood something.

Thank you in advance!

user485624
  • 141
  • 2
  • 2
  • 4

1 Answers1

7

I would recommend turning to Apache Commons:

  • FileUpload handles the server-side, and parses multi-part posts.
  • HttpClient for the client-side, for constructing those posts.

But before you do any of that, I think you need to talk with whoever has set you on this task, to be sure that you understand exactly what he/she wants. Because multi-part for mail processing is close but not quite the same as multipart for file uploads.

Anon
  • 2,654
  • 16
  • 10
  • Thank you for the answer! Is there a way to send multipart http requests using only the standard java API, i.e. without external libraries like HttpClient? – user485624 Jan 10 '11 at 21:58
  • 1
    @user485624 - sure. You just need to read and understand the relevant RFC's, and write the appropriate content to a `HttpURLConnection`. But that would be foolish, given that Jakarta already has a complete and tested implemntation. – Anon Jan 11 '11 at 15:06