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 Receiving multipart request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Receiving multipart request" Watch "Receiving multipart request" New topic
Author

Receiving multipart request

Lloyd Lamington
Greenhorn

Joined: Jul 06, 2009
Posts: 2
Hi,

I have written a code to upload the files to a server on the client side using multipart.. I would like to know how to receive these files on the server side. Can anybody provide me with the sample code ?

Thanks,
Lloyd
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

As you are uploading the files from client to the server, your files are already recieved on the server.


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Lloyd Lamington
Greenhorn

Joined: Jul 06, 2009
Posts: 2
i am actually running a servlet on my machine to get the multipart request. I need to write the code to get the multipart request in the servlet.

Thanks
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
I did'nt get you. You are saying that you want a servlet on server side that handles multipart requests but you are currently doing this locally on your machine then, why dont you write your servlet code running locally into the servlet thats running on the server ?
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

try using apache commons fileupload.
read here all about file upload


in your servlet
import org.apache.commons.fileupload.*;





To use the "FileItems" in items, you would iterate through the list and check each item to see if it is a form field or not.
contents form fields would get processed as strings. non-form fields can be treated as files. uploaded files should be saved using streams instead of trying to store the contents in memory.

again, the link explains everything, including tracking progress of uploads, dealing with antivirus scanners, and cleaning up temp files. enjoy.
Charbel Keyrouz
Ranch Hand

Joined: Jun 10, 2005
Posts: 46
check this site as well (oreilly's cos.jar)
http://www.jguru.com/faq/view.jsp?EID=1045507
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Receiving multipart request