js|word| Object | download
<% @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 ("appearing ioexception." + e);
finally {
if (bis!= null)
Bis.close ();
if (BOS!= null)
Bos.close ();
}
Return
%>