<%@ page contentType="text/html;charset=gb2312" import="java.io.*"%><%
    try{
  String str=request.getParameter("name1");//获得响应客户的输出流
  str=new String(str.getBytes("iso8859-1"),"gb2312");
  File fileLoad=new File("f:\\tools\\xiazai",str);//下载文件
  response.reset();
  OutputStream o=response.getOutputStream();   BufferedOutputStream bos=new BufferedOutputStream(o);
  byte b[]=new byte[500];//输出文件用的字节数组,每次发送500个字节到输出流
  response.setHeader("Content-disposition","attachment;filename="+new String(str.getBytes("gb2312"),"iso8859-1"));   response.setContentType("application/x-tar");//通知客户文件的mime类型
  long fileLength=fileLoad.length();//通知客户文件的长度
  String length=String.valueOf(fileLength);
  response.setHeader("Content_Length",length);
  FileInputStream in=new FileInputStream(fileLoad);//读取文件并发送给客户下载
  int n=0;
  while((n=in.read(b))!=-1)
  {
      bos.write(b,0,n);
  }
   bos.close();
   }
    catch(Exception e){
out.println("发生了异常"+e);
 }
 response.reset();
 %>
希望大家注释详细点,特别那个”response.reset()与response.setHeader()方法,按照书上说的我理解的不透希望大家帮我讲一下。这句也是第一次见,也不懂:""Content-disposition","attachment;filename"
再次谢谢大家了