• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Receiving multipart request

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As you are uploading the files from client to the server, your files are already recieved on the server.
 
Lloyd Lamington
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this site as well (oreilly's cos.jar)
http://www.jguru.com/faq/view.jsp?EID=1045507
 
Lookout! Runaway whale! Hide behind this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!