• Post Reply Bookmark Topic Watch Topic
  • New Topic

download zip file with servlet : Bad CRC  RSS feed

 
Susilo Saja
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my servlet is trying to put a zip file as the response.
_res.setContentType("application/zip");
_res.setHeader("Content-Disposition","inline; filename=soso.zip;");
I read the source zip file using File & FileInputStream, then write to the response.
In the client, the file was succesfully saved as a zip file. But when I try to extract it using WinZip, it gave me error :"Bad CRC 8115541a (should be 09b8193f)"
The source zip file was fine. When I view both the
files in UltraEdit, which show me those strange characters (don't know how to call it), there were some characters that is different between the source zip file and the downloaded zip file.
for example, in the source file the character � was changed to ? in the downloaded file.
can someone help me about this? sorry my posting was rather long
 
Susilo Saja
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it turns out that the error is the same when I try to put a gif file as the response.

_res.setContentType("image/gif");

PrintWriter out = _res.getWriter();
File f = new File ("D:\\exp.gif");
FileInputStream fis = new FileInputStream (f);
byte[] b = new byte[fis.available()];
fis.read (b, 0, b.length);

String s = new String (b);
System.out.println (s);
out.print (s);
out.flush();
When I do System.out.println (s), the result is still correct. But when it go to client, some characters was changed, so the image was corrupted.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!