0

I need to send X number of files to my servlet from an applet, which is the best way to do this? And I need to send before the files, a java object populated. I need to do it all in a single connection.

I'll upload my applet 3 ~ 10mb to my servlet.

I currently use FileInput together with the OutputStream and BufferedOutputStream to send a file, causing the buffer size is 8K.

First time I'll try to zip all the files to upload a zip file to the servlet, but I know it's not a good solution.

fhgomes_ti
  • 145
  • 2
  • 14

1 Answers1

1

In the Applet side, send it as a normal multipart/form-data request by either URLConnection or HttpClient. In the Servlet side, use either HttpServletRequest#getParts() or Commons FileUpload to extract the parts from the request. This way the applet and servlet are not tight coupled to each other, but just reuseable on different servers (e.g. PHP) and/or clients (e.g. a simple HTML page).

Whether or not to zip the individual files into a single zip file is a decision you'd need to make yourself based on coding and performance impact.

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • I'll try that. Sorry it may take to respond, and can not test now. For now i could send an object and a single zip file. – fhgomes_ti Dec 22 '11 at 21:38