%@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 ( "出現(xiàn)IOException." + e );
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
return;
%>
標(biāo)簽:紹興 北海 玉樹 肇慶 潮州 廣元 吳忠 保定
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用JSP下載word文件(不會直接用IE打開)》,本文關(guān)鍵詞 用,JSP,下載,word,文件,不會,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。下一篇:幾則JSP入門知識總結(jié)