response.setContentType("bin");
我没这样用过。可能是你这错了吧。

解决方案 »

  1.   

    swf=application/x-shockwave-flashmimeype是这个
      

  2.   

    response.setContentType("application/msword");
      

  3.   

    <%@page contentType="text/html; charset=gb2312"%> 
    <%@ page import="java.io.*" %>
    <%@ page import="java.net.*" %>
    <%
    String filePath=(String)(request.getParameter("filePath"));
    String filename=(String)(request.getParameter("filename"));

    //Download
    File file = new File(filename);

    // 设置HTTP头:
    response.reset();
    response.setContentType("application/octet-stream; charset=UTF-8");
    response.addHeader("Content-Disposition","attachment; filename= \"" + file.getName() + "\"");
    response.setContentLength((int)file.length());

    byte[] buffer = new byte[4096];
    BufferedOutputStream output = null;
    BufferedInputStream input = null;// 写缓冲区:
    try
    {
        output = new BufferedOutputStream(response.getOutputStream());
        input = new BufferedInputStream(new FileInputStream(file.getPath()));    int n = (-1);
        do
        {
             n = input.read(buffer, 0, 4096);
             if(n!=(-1))
                 output.write(buffer, 0, n);
         }while(n!=(-1));
        response.flushBuffer();
    }
    catch(Exception e) {} // maybe user cancelled download
    finally
    {
        if(input!=null) input.close();
        if(output!=null) output.close();
    }//Delete File;
    file.delete();//Delete Directory
    File Directory = new File(filePath);
    Directory.delete();
    %>
      

  4.   

    如果代码定在JSP页面中。要将所有换行和空格都去掉。不然会出现问题。