tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vikas <viksd2...@yahoo.co.in>
Subject Creating zip output stream in jsp
Date Tue, 13 May 2003 17:23:35 GMT

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
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message