File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes what is multipart request? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "what is multipart request?" Watch "what is multipart request?" New topic
Author

what is multipart request?

Laxmikant Kumbhare
Ranch Hand

Joined: Sep 19, 2011
Posts: 38
What is multipart request?
Please tell me in brief?
Where it can be used?
Clivant Yeo
Ranch Hand

Joined: May 22, 2004
Posts: 124
Do you mean HTTP multipart request?

If that's the case, a HTTP multipart request is a type of HTTP request that HTTP clients construct to send file and data over to the server side.

I had written a post on this topic in C#. You could probably look at the first few sections to get an understanding on that.

Hope it helps!


Clivant Yeo
My Personal Website
Laxmikant Kumbhare
Ranch Hand

Joined: Sep 19, 2011
Posts: 38
Actually I need some theorotical answer.
Clivant Yeo
Ranch Hand

Joined: May 22, 2004
Posts: 124
What is a HTTP multipart request?

It is a type of HTTP request that HTTP client construct to send information to the server.

An example:

POST http://127.0.0.1/GetPostRequest.php HTTP/1.1
Host: 127.0.0.1
Connection: keep-alive
Referer: http://localhost/GetPostRequest.php
Content-Length: 1611568
Cache-Control: max-age=0
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryX6nBO7q27yQ1JNbb
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

------WebKitFormBoundaryX6nBO7q27yQ1JNbb
Content-Disposition: form-data; name="myFileDescription"

My sample file description.
------WebKitFormBoundaryX6nBO7q27yQ1JNbb
Content-Disposition: form-data; name="myFile"; filename="SomeRandomFile.pdf"
Content-Type: application/pdf

file contents...
------WebKitFormBoundaryX6nBO7q27yQ1JNbb--

Notice the string "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryX6nBO7q27yQ1JNbb".

This is the part that tells the server:
1) the HTTP request is a multipart request
2) The separator between different chunks of data.

In the example, there are two pieces of information:
1) A form data "myFileDescription" with value My sample file description.
2) A file named as "SomeRandomFile.pdf" and its contents.

Where it can be used?

It is used by browsers and HTTP clients to upload files to the server.

Hope this helps.
Laxmikant Kumbhare
Ranch Hand

Joined: Sep 19, 2011
Posts: 38
Yes, Obviously it was helpful.

Thank you very much!
Clivant Yeo
Ranch Hand

Joined: May 22, 2004
Posts: 124
You are most welcome!
Laxmikant Kumbhare
Ranch Hand

Joined: Sep 19, 2011
Posts: 38
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is multipart request?