<%@ page language="java" contentType="application/bin"
import="java.io.FileInputStream,java.io.OutputStream,java.io.IOException,java.io.File"%><%@ page import="java.net.URLEncoder"%><%
String exportfilepath = (String) request.getAttribute("exportfilepath");
String exportfilename = (String) request.getAttribute("exportfilename");
request.removeAttribute("exportfilepath");
request.removeAttribute("exportfilename");
if (exportfilepath != null && exportfilename != null) {
response.reset();
response.setContentType("application/bin");
String filenamedownload = exportfilepath;
String filenamedisplay = exportfilename;
filenamedisplay = URLEncoder.encode(filenamedisplay, "UTF-8");
response.setHeader("Content-Disposition",
"attachment;filename=" + filenamedisplay);
OutputStream output = null;
FileInputStream fis = null;
try {
output = response.getOutputStream();
fis = new FileInputStream(filenamedownload);
byte[] b = new byte[1024];
int i = 0;
while ((i = fis.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
}catch(IOException ex){
ex.printStackTrace();
}finally {
if (fis != null) {
fis.close();
fis = null;
}
if (output != null) {
output.close();
output = null;
}
}
// try{
// File thefile=new File(icalendarfilepath);
// if (thefile.exists()){
// thefile.delete();
// }
// }catch(Exception e){
//
// }
}else{
out.print("Sorry, there are some errors on the server and the application could not generate"
+" the ICalendar file successfully. Please contact with the administrator.");
}
%>
分享到:
相关推荐
JSP下载文件源代码,利用jsp-SmartUpload实现,代码简单,使用方便,调用简单。
jsp 下载文件 直接引用该文件即可
用java写的文件上传和下载,上传到硬盘物理路劲下,上传后用io读取txt文本文件,修改不能上传和下载是中文名称的bug,简单易用
使用jsp下载excel文件 JSP文件下载后台生成的excel文件到本地机。
实现jsp页面的下载功能,文档下载,文件下载,软件下载,测试过好用。
"JSP实现文件上传与下载" JSP(Java Server Pages)是一种动态网页技术,用于开发基于Web的应用程序。...JSP文件上传和下载是Web应用程序中常用的功能,需要注意文件上传和下载的安全性、性能和可扩展性。
第一中使用二进制流的方式,这样被文件的文件可以是随意地址,二不必使用“/”开头的路径;...第二种使用RequestDispatcher下载文件,这中下载方式的局限是被下载文件的路径必须以“/”开头,即在项目的webRoot下
jsp文件下载功能,没有什么好说的,新手学习,呵呵。为什么为要二十个字呢。,。。
一个基于myeclipse开发平台的jsp文件上传、文件下载实例
jsp 实现 文件下载 jspsmartupload
java+jsp实现文件下载, 1、downloadtool.jsp为进入下载的页; 2、dodownloadtool.jsp实现下载;有详细的注释! 希望能帮到各位!
可直接导入eclipse中运行 博文链接:https://coderdream.iteye.com/blog/249824
完整的讲述了基于jsp的文件上传下载功能,具体讲解见http://blog.csdn.net/it_tingge/article/details/49025273
用JSP下载word文件(不会直接用IE打开.rar
JSP实现文件的上传与下载,方便大家参考使用,实在方便,用到了文件上传组件,但是下载没有,大家参考参考学习学习,定会有所收获的。
在用JSP下载某些文件时,可能会碰到文件直接用IE打开了的情况。下面的方法可以解决这问题: downloadTest.jsp: ; charset=EUC-JP" language="java" %> *"%> *"%> *"%> <!DOCTYPE ...
使用JSP实现上传下载文件jspSmartUpload 里面讲述怎么用jsp实现
利用jsp实现文件上传下载,将文件上传到tomcat服务器之后下载。
用Jsp来实现文件下载功能的几种方式
java+jsp代码实现从FTP服务器上传下载文件。 里面给了java方法和jsp页面的代码。主要是实现从FTP服务器上面下载文件到自己本地文件夹下面。另外还给了几个网站供大家参考。