jsp下载问题。
如果浏览器上有装迅雷之类的插件,会导致下载一个jsp或者html。我总不能每个客户去教他把浏览器上的插件删掉。
请问怎样解决,只用浏览器下载?
下面为下载页面。
<%
//打开指定文件的流信息
String filepath = (String) request.getAttribute("filePath"); //导出文件的路径
filepath = filepath.replace("@", "\\");
String fileName = (String) request.getAttribute("fileName"); //文件名
System.out.println(" filepath + fileName : " + filepath+"\\"+fileName);
FileInputStream fs = null;
try {
fs = new FileInputStream(new File(filepath+"\\"+fileName));
}
catch(FileNotFoundException e)
{
e.printStackTrace();
return;
}
//设置响应头和保存文件名
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename=\""+fileName+"\"");
//写出流信息
int b = 0;
try
{
OutputStream ops = response.getOutputStream();
while((b=fs.read())!=-1)
{
ops.write(b);
}
fs.close();
out.clear();
out = pageContext.pushBody();
System.out.println("开始删除");
FileUtil.delAllFile(filepath); //删除所有文件
System.out.println("删除完成");
}
catch(Exception e)
{
e.printStackTrace();
}
%>