<% @ Page contenttype = "text/html; charset = gb2312" Import = "Java. Io. *" %>
<%
String url = request. getparameter ("url ");
String templatecontent = "[internetshortcut]" + "/N"
+ "Url = http: // localhost: 7001/jcewweb ";
String realfilename = "Jincheng Information Management System" + ". url ";
String upurl = request. getrealpath ("// upload // URL //");
String filename = upurl + "//" + realfilename;
Fileoutputstream = new fileoutputstream (filename); // create a file output stream
Byte tag_bytes [] = templatecontent. getbytes ();
Fileoutputstream. Write (tag_bytes );
Fileoutputstream. Close ();
Try {
File file = new file (upurl, realfilename );
Bufferedinputstream Bis = new bufferedinputstream (
New fileinputstream (File ));
Byte [] buffer = new byte [111000];
Realfilename = java.net. urlencoder. encode (realfilename,
"Gb2312 ");
Realfilename = java.net. urldecoder. Decode (realfilename,
"Iso8859_1 ");
Response. Reset ();
Response. setcharacterencoding ("UTF-8 ");
Response. setcontenttype ("application/X-download"); // different types of files correspond to different MIME types
Response. setheader ("content-disposition ",
"Attachment; filename =" + realfilename );
Outputstream OS = response. getoutputstream ();
While (bis. Read (buffer)> 0 ){
OS. Write (buffer );
}
Bis. Close ();
OS. Close ();
} Catch (exception e ){
E. printstacktrace ();
}
%>