The main code of the program is now posted, for everyone's needs when referenced under:
<% @page import= "java.util.*, java.net.*, java.text.*, java.util.zip.*, java.io.*"%> <%!
Static vector expandfilelist (string[] files, boolean incldirs) {vector v = new vector ();
if (files = null) return V;
for (int j=0 J < files.length; i++) V.add (New File (Urldecoder.decode (FILES[J)));
for (int i=0 i < v.size (); i++) {File F = (file) v.get (i);
if (F.isdirectory ()) {file[] fs = F.listfiles ();
for (int n = 0; n < fs.length n++) V.add (fs[n));
if (!incldirs) {v.remove (i);
i--;
}} return v;
Class Writer2stream extends outputstream{Writer out;
Writer2stream (Writer W) {super ();
out = W;
public void write (int i) throws ioexception{out.write (i);
public void Write (byte[] b) throws ioexception{for (int j=0;j<b.length;j++) {int n=b[j];
Convert byte to Ubyte n= ((n>>>4) &0xf) *16+ (N&0XF);
Out.write (n); } public void Write (byte[] b, int off, int len) throws Ioexception{for (int j = off, J < off + Len; j + +) {int n=b[j];
n = ((n>>>4) &0xf) *16+ (N&0XF);
Out.write (n);
%> <%/////Download Compressed package Vector v = expandfilelist (request.getparametervalues ("Selfile"), false);
if (v.size () = = 0) {request.setattribute ("error", "No files selected");
} else{File Dir_file = new file (Request.getrealpath ("") + "/myfile/");
int dir_l = Dir_file.getabsolutepath (). Length ();
Response.setcontenttype ("Application/zip");
Response.setheader ("Content-disposition", "Attachment;filename=" Downloadname.rar ")";
Out.clearbuffer ();
Zipoutputstream zipout = new Zipoutputstream (new Writer2stream (out));
Zipout.setcomment ("Download Selected files nas one WinRAR file:ndownloadname.rar");
Zipout.setlevel (1);
for (int i=0;i<v.size (); i++) {File f = (file) v.get (i);
if (F.canread ()) {Zipout.putnextentry (New ZipEntry (F.getabsolutepath (). substring (dir_l+1))); Bufferedinputstream FR = new BufferedinputstreaM (New FileInputStream (f));
byte buffer[] = new BYTE[0XFFFF];
int b;
while ((B=fr.read ())!=-1) Zipout.write (b);
Fr.close ();
Zipout.closeentry ();
} zipout.finish ();
Out.flush (); }%>