下载的源程序
<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.io.File" %>
<%
StringBuffer sb = new StringBuffer();
String path = request.getSession().getServletContext().getRealPath("index.jsp");
out.println(path);
ServletOutputStream outPut = response.getOutputStream();
if (path != null)
{
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;filename=\"" + "index.jsp" + "\"");
FileInputStream in = new FileInputStream(new File(path));
int length = 0;
byte[] buf = new byte[512];
if (in != null)
{
while (((length = in.read(buf)) != -1))
{
outPut.write(buf, 0, length);
}
outPut.flush();
}
}
%>