<% @ Page contentType = "application/x-xls; charset = GBK" %>
<% @ Page import = "java. io. File, java. io. FileInputStream" %>
<% @ Page import = "javax. servlet. ServletOutputStream" %>
<%
Out. clear ();
Out = pageContext. pushBody ();
String fileName = request. getParameter ("fileName ");
Response. setHeader ("Content-disposition", "inline; filename =" + fileName );
File fileLoad = new File (request. getRealPath ("") + "/shipment/template", fileName );
Long fileLength = fileLoad. length ();
String length = String. valueOf (fileLength );
Response. setHeader ("Content_Length", length );
FileInputStream input = null;
ServletOutputStream output = null;
Try {
Input = new FileInputStream (fileLoad );
Output = response. getOutputStream ();
Byte [] block = new byte [1024];
Int len = 0;
While (len = input. read (block ))! =-1 ){
Output. write (block, 0, len );
}
} Catch (Exception e ){
E. getMessage ();
} Finally {
Try {
Input. close ();
Output. flush ();
Output. close ();
} Catch (Exception ex ){
Ex. getMessage ();
}
}
%>
Author: ERDP Technical Architecture"