<% @ Page import = "Java. util. *" %>
<% @ Page import = "Java. Io. *" %>
<% @ Page import = "java.net. *" %>
<%
String filename = "";
If (request. getparameter ("file ")! = NULL ){
Filename = request. getparameter ("file ");
}
Response. setcontenttype ("application/MSWord ");
Response. setheader ("content-disposition", "attachment; filename =" + filename );
Bufferedinputstream Bis = NULL;
Bufferedoutputstream Bos = NULL;
Try {
Bis = new bufferedinputstream (New fileinputstream (getservletcontext (). getrealpath ("" + filename )));
Bos = new 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 (final ioexception e) {
system. out. println ("ioexception. "+ E);
}finally {
If (Bis! = NULL)
bis. Close ();
If (Bos! = NULL)
Bos. Close ();
}< br> return;
%>