You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vikas <vi...@yahoo.co.in> on 2003/05/13 19:23:35 UTC

Creating zip output stream in jsp

Hi ,

I want to create zip file from a string in jsp.My code is creating zip but when I am trying to extract it gives error .I am not able to extract file from archieve.The log file for zip shows there are some extra byte present in zip.

below is my code in jsp

byte b[]=new byte[128];

stfinal ="Helloadasdasdasd";

ByteArrayOutputStream bout = new ByteArrayOutputStream();
 ZipOutputStream zout=new ZipOutputStream(bout);
 zout.putNextEntry(new ZipEntry("file.html"));

InputStreamReader input = new InputStreamReader(new StringBufferInputStream (stfinal));

 int numRead=0;
 int size=0;

while (numRead != -1) {
   numRead = input.read(b,size,1000);
   size+=numRead;
   }

zout.closeEntry();
 zout.finish();
 out.flush();
 String zip=bout.toString();
 res.setContentType("application/zip");
 res.setHeader("Content-Disposition","inline; filename=output.zip;")

out.println(zip);

When i switched to servlet I got below error

Not an ISO 8859_1 character

 

Can anyone pls help me how to create zipoutputstearm in jsp

 


******
Viks
******
Catch all the cricket action. Download Yahoo! Score tracker