aspose file tools*
The moose likes Servlets and the fly likes How to send a Zip file to CLient Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to send a Zip file to CLient " Watch "How to send a Zip file to CLient " New topic
Author

How to send a Zip file to CLient

krishna sannidhi
Greenhorn

Joined: Jun 03, 2010
Posts: 1

i am getting the compressed (zipped) folder is invalid or corrupted on UI screen upon selecting the open button on dialog box. please help me out.......

HttpServletResponse response = HttpJSFUtil.getResponse();
File f = new File("C:\\Krishna\\AL3Files.zip");

OutputStream outputStream;
try {
outputStream = response.getOutputStream();

response.setContentType("application/zip");
response.setHeader("Content-Disposition","inline; filename=AL3Files.zip;");

byte[] arBytes = new byte[(int) f.length()];
FileInputStream is= new FileInputStream(f);
is.read(arBytes);
outputStream.write(arBytes);
outputStream.flush();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3220
    
  49

Hello Krishna, welcome to JavaRanch
Please UseRealWords instead of Invali, thi, pblm,.... and please UseCodeTags when you post a code.
Can you please click the button and make them changed?


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
 
 
subject: How to send a Zip file to CLient