如何在JSP中实现“选择文件保存路径”,请帮忙,解决马上送分。 先弄个文件对话框,然后将选择的路径:new File("../_Bak/file.txt"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道你的意思是不是说弹出“下载文件对话框”,我原先作过一个在jsp中实现文件动态下载的程序http://dag.suse.edu.cn/introduce/如果是的话,你可以用这个Email跟我联系:[email protected]全部原代码免费提供 谢谢大家,是我没说清楚。我做一个简单的备份数据库的程序,需要用户选择备份文件的路径,希望有“保存文件”那样的对话框。 谢谢你,BillyW(阿弥陀佛) ,能给一下applet实现的源代码吗?或者是具体一点的思路也好! 直接以流方式write出来也可以实现 希望有“保存文件”那样的对话框。 -------------------这不就是弹出下载文件对话框吗写个servlet调用我这个方法 private void down_FILE(HttpServletRequest req,HttpServletResponse resp,String szPath_file,String szFile_name) { String szServer_path=""; szServer_path=szPath_file; BufferedInputStream bis = null; BufferedOutputStream bos = null; try { //和java.io.PrintWriter out 不能共用 ServletOutputStream outm = null; try { outm=resp.getOutputStream(); } catch(Exception e) { exceptionOutput(resp,e.toString()+" abcd"); } resp.setContentType( "application/octet-stream" ); // MIME type for exe resp.setHeader("Content-disposition","attachment; filename="+szFile_name);//显示的随机文件名,可以用这个保存或另起一个名 // Open file File f1; szServer_path = szServer_path+"filename.xls" ; try { f1=new File(szServer_path); FileInputStream fis=new FileInputStream(f1); bis = new BufferedInputStream(fis); bos = new BufferedOutputStream(outm); byte[] buff = new byte[2048]; int bytesRead; while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } } catch(Exception e) { } } finally { try { if (bis != null) bis.close(); if (bos != null) bos.close(); } catch(IOException e) { } } } 毕设最后问题( 重谢) ResultSet如何读取oracle的CLOB类型字段??? 在frame框架下,用java获得地址栏信息 异常处理问题 急,有关MAP(地图)显示的问题,请进来看看 进入首页调用其他页面,但又不想地址栏改变,怎么做? jsp 问题 请问这是什么错误?????????????? 超级菜鸟问题,jsp公共方法(.class文件)应该放到哪儿啊~ 请问高手,我怎样在jsp中取得javascript中定义好的数组???(急急急 在线等待) 一个"jsp+javabean"小程序出现了问题,请大师帮我解决一下。 又见NullPointerException,望解!
http://dag.suse.edu.cn/introduce/
如果是的话,你可以用这个Email跟我联系:[email protected]
全部原代码免费提供
-------------------这不就是弹出下载文件对话框吗写个servlet调用我这个方法
private void down_FILE(HttpServletRequest req,HttpServletResponse resp,String szPath_file,String szFile_name)
{
String szServer_path="";
szServer_path=szPath_file;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try
{
//和java.io.PrintWriter out 不能共用
ServletOutputStream outm = null;
try
{
outm=resp.getOutputStream();
}
catch(Exception e)
{
exceptionOutput(resp,e.toString()+" abcd");
}
resp.setContentType( "application/octet-stream" ); // MIME type for exe
resp.setHeader("Content-disposition","attachment; filename="+szFile_name);//显示的随机文件名,可以用这个保存或另起一个名
// Open file
File f1;
szServer_path = szServer_path+"filename.xls" ;
try
{
f1=new File(szServer_path);
FileInputStream fis=new FileInputStream(f1);
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(outm);
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
{
bos.write(buff, 0, bytesRead);
} }
catch(Exception e)
{
}
}
finally
{
try
{
if (bis != null) bis.close();
if (bos != null) bos.close();
}
catch(IOException e)
{
}
}
}