栏目导航
热点推荐
- 测试你对技术的掌握度:JSP程序
- Eclipse 3.0 上配置JSP开发环境
- Jsp基础知识总结
- 整合Tomcat4.1和IIS5 直到能够正
- JSP服务器的安装与配置(带数据库
- 在JSP环境中如何配置和使用fcked
- JSP中表单数据存储的通用方法
- 在JSP环境中如何来配置和使用fck
- Oracle数据库和JSP连接要注意的
阅览排行
Jsp页面实现文件上传下载
www.jz123.cn 2008-09-02 来源: 中国建站 袁袁整理 我要投递新闻
* @param fileName
*/
public void setDisFileName(String fileName){
this.disFileName = fileName;
}
/**
* set zip file path
* @param fileNames
*/
public void setZipFilePath( String path ){
this.zipFilePath = path;
}
public void setZipDelFlag(boolean b){
this.zipDelFlag = b;
}
/**
* set zip file names
* @param fileNames
*/
public void setZipFileNames(String[] fileNames){
this.zipFileNames = fileNames;
}
/**
* set download file name
* @param fileName
*/
public void setDownFileName(String fileName){
this.downFileName = fileName;
}
/**
* set file content
* @param fileContent
*/
public int setFileContent(String fileContent){
try{
byte[] buffs = fileContent.getBytes("UTF-8");
response.getOutputStream().write(buffs);
}catch(IOException e){
return IO_EXCEPTION;
}
return PROCESS_OK;
}
/**
* set file content
* @param fileContent
*/
public int setFileContent(byte[] fileContent){
try{
response.getOutputStream().write(fileContent);
}catch(IOException e){
return IO_EXCEPTION;
}
return PROCESS_OK;
}
/**
* set file content end
*
*/
public int setFileContentEnd(){
try{
response.getOutputStream().close();
}catch(IOException e){
return IO_EXCEPTION;
}
return PROCESS_OK;
}
/**
* main process
* @return
*/
public int process(){
int status = PROCESS_OK;
status = preCheck();
if ( status != PROCESS_OK )
return status;
String fileName = disFileName;
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition","attachment;filename=\"" + fileName + "\"");
int BUFSIZE = 1024 * 8;
int rtnPos = 0;
byte[] buffs = new byte[ BUFSIZE ];
0
上一篇:JSP网站开发环境的目录结构标准 下一篇:Jsp常用功能:CSV文件的生成与分析