<%
Java. Io. bufferedinputstream Bis = NULL;
Java. Io. bufferedoutputstream Bos = NULL;
Try {
String filename = request. getparameter ("FILENAME ");
Response. setcontenttype ("application/X-msdownload ");
Response. setheader ("content-disposition", "attachment; filename =" + filename );
// Request. getrealpath ("downloads/" + filename)
Bis = new java. Io. bufferedinputstream (New fileinputstream (config. getservletcontext (). getrealpath ("downloads/" + filename )));
Bos = new java. Io. bufferedoutputstream (response. getoutputstream ());
Byte [] buff = new byte [2048];
Int bytesread;
While (-1! = (Bytesread = bis. Read (buff, 0, Buff. Length ))){
Bos. Write (buff, 0, bytesread );
}
}
Catch (exception e ){
E. printstacktrace ();
}
Finally {
If (Bis! = NULL) bis. Close ();
If (Bos! = NULL) Bos. Close ();
}
%>
/// Note: the filename parameter is used to pass the file name. Chinese characters are not supported.