我没做过JAVA WEB 开发,现在需要提供一个类似于http://123.234.345.456/soft/update/AAA.zip
的URL地址给别人下载AAA.zip用。请问这个服务器怎么搭建?我安装好了jdk1.6和apache-tomcat-7.0.19-windows-x86,配置好了环境变量。
在Eclipse装了web开发的插件,新建了一个web项目mywebpro,添加了一个index.jsp
目前可以通过http://123.234.345.456:8080/mywebpro 正常访问index.jsp请问下面是怎么个做法,能让别人通过一个url下载我的AAA.zip?
的URL地址给别人下载AAA.zip用。请问这个服务器怎么搭建?我安装好了jdk1.6和apache-tomcat-7.0.19-windows-x86,配置好了环境变量。
在Eclipse装了web开发的插件,新建了一个web项目mywebpro,添加了一个index.jsp
目前可以通过http://123.234.345.456:8080/mywebpro 正常访问index.jsp请问下面是怎么个做法,能让别人通过一个url下载我的AAA.zip?
解决方案 »
- weblogic的一个问题啊
- 菜鸟初学Struts2被无限404蹂躏两夜!求拯救
- 向Mysql添加数据 中文乱码 怎么解决
- 怎么自动生成申请书号
- Mysql的一个报错java.sql.SQLException: Unknown column 'id' in 'order clause'
- 求一个JAVA字体插件!!
- 怎么在web项目里的web-xml中配置出错后跳转的页面
- sql server 多字段更新问题
- 我在windows2000下运行tomcat,需要加运行的lib和class或者jar文件入环境变量。除了在我的电脑-》属性-》环境变量中改变,还可以怎做!
- 怎样消除页面刷新中的刺耳声音
- extjs画表格的问题
- open flash chart ie无法显示问题
http://www.cnblogs.com/ungshow/archive/2009/01/12/1374491.html
PS:头像是我自己从游戏中截图做的,几年前就在用了。
<a href="down.jsp?filename=AAA.zip"> AAA文件</a>3.将down.jsp 放至mywebpro 下.内容为<%
response.reset();//可以加也可以不加
response.setContentType("application/x-download");
String filename=request.getParameter("filename");
String filenamedownload ="/soft/update/"+filename;
System.out.println(filenamedownload);
String filenamedisplay =filename;//系统解决方案
filenamedisplay = URLEncoder.encode(filenamedisplay,"UTF-8");
response.addHeader("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(Exception e)
{
System.out.println("Error!");
e.printStackTrace();
}
finally
{
if(fis != null)
{
fis.close();
fis = null;
}
if(output != null)
{
output.close();
output = null;
}
}
%>