0

I was wondering if anyone could tell me how to code a servlet which can receive a zip file in http request?

I googled but didn't find anything. If a zip file can't be sent using http request then please suggest an alternative

I'm not asking for examples on how to upload a file using a servlet. I need to know if a file can be sent to a servlet and if yes, then how?

For instance, if a string is sent to a servlet and you use the following code to get it: String value = req.getParameter(name);

but what if a file is sent? Can this be done?

Thanks in advance

sap
  • 1,141
  • 6
  • 41
  • 62
  • 2
    Have you considered Apache Commons FileUpload? http://commons.apache.org/fileupload/using.html – Kenny Apr 12 '12 at 20:46

1 Answers1

2

Any file can be uploaded, there's no distinction if it is a zip or text file.

Just google "servlet file upload" for many results. One example is this: How to upload files to server using JSP/Servlet?

Community
  • 1
  • 1
Ata S.
  • 890
  • 7
  • 12
  • I'm not asking for examples on how to upload a file using a servlet. I need to know if a file can be sent to a servlet and if yes, then how? – sap Apr 12 '12 at 20:51
  • 1
    It is yes, and the link I gave explains how. Receiving a file through http request equals uploading a file. But the request keyword here is in "network" mean, so that request should be a multipart formdata request. You can't send or receive a file with GET requests. In addition, you can even simulate the client-end so the client doesn't necessarily send the data through a browser or html interface. – Ata S. Apr 12 '12 at 20:55