jsp浏览器
源代码在线查看: down.jsp
//文件管理系统 V1.0
//2009-2-17
//woody_2006@163.com
String file = new String(request.getParameter("file").getBytes("iso-8859-1"),"GBK");
String curName = "";
if(!Tool.isEmp(file))
{
String[] tmp = file.split("/");
if(tmp.length>1)
{
curName = tmp[tmp.length-1];
}
}
OutputStream o = response.getOutputStream();
File fileLoad = new File(file);
response.reset();
response.setContentType("application/x-msdownload;charset=gb2312;");
response.setHeader("content-disposition","attachment;filename="+new String(curName.getBytes("GBK"),"iso8859-1"));
long fileLength = fileLoad.length();
String length1 = String.valueOf(fileLength);
response.setHeader("Content_Length", length1);
FileInputStream in = new FileInputStream(fileLoad);
int n;
byte[] b = new byte[(int)fileLength];
while ((n = in.read(b)) != -1)
{
o.write(b, 0, n);
}
in.close();
o.close();
%>