output.jsp
----------------------------------<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import ="java.io.*"%>
<%@ page import ="java.lang.*"%>
<form></form><%
String fileName=request.getParameter("fileanme"); //file name and path
String cType="application/msword"; //指定输出的类型
response.setContentType(cType);
ServletOutputStream outs = response.getOutputStream();
FileInputStream ins = new FileInputStream(fileName);
int bit = 256;
int i = 0;
try {
while ((bit) >= 0) {
bit = ins.read();
outs.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
outs.flush();
outs.close();
ins.close();
%>
--------------------------------------
链接:<a href="output.jsp?filename="+<%=name%> > 打开文件 </a>name为你要打开的文件的路径+文件名
----------------------------------<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import ="java.io.*"%>
<%@ page import ="java.lang.*"%>
<form></form><%
String fileName=request.getParameter("fileanme"); //file name and path
String cType="application/msword"; //指定输出的类型
response.setContentType(cType);
ServletOutputStream outs = response.getOutputStream();
FileInputStream ins = new FileInputStream(fileName);
int bit = 256;
int i = 0;
try {
while ((bit) >= 0) {
bit = ins.read();
outs.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
outs.flush();
outs.close();
ins.close();
%>
--------------------------------------
链接:<a href="output.jsp?filename="+<%=name%> > 打开文件 </a>name为你要打开的文件的路径+文件名
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货