谁有下载文件(可运行JSP)程序给个呀!!!!!!!!!!

解决方案 »

  1.   

    <a href="test/javadoc.rar">下载</a>文件后缀不要有jsp,html
      

  2.   

    <%@ page contentType="text/html;charset=GB2312" %>
    <HTML>
    <BODY>
    <P>点击超链接下载Zip文档book.Zip
     <BR>  <A href="loadFile.jsp">下载book.zip</a>
    </Body>
    </HTML>
      

  3.   

    TO:xiongbing528(多情剑客无情剑)
    晕! 我要的就是loadFile.jsp文件呀!
      

  4.   

    那么多人不是已经回答你了么,用一个超链接就可以了。
    比如你现在有一个文件叫做a.zip,你要让用户下载,你用添加一个超链接,指向a.zip就可以了。<a href='....../a.zip'>下载文件</a>用户只要点这个链接就可以下载文件了。
      

  5.   

    写个下载servlet 配置一下就能用了import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.net.*;public class DownloadServlet extends HttpServlet {
        private String contentType = "application/x-msdownload";
        private String enc = "utf-8";
        private String fileRoot = "";    public void init(ServletConfig config) throws ServletException {
            String tempStr = config.getInitParameter("contentType");
            if (tempStr != null && !tempStr.equals("")) {
                contentType = tempStr;
            }
            tempStr = config.getInitParameter("enc");
            if (tempStr != null && !tempStr.equals("")) {
                enc = tempStr;
            }
            tempStr = config.getInitParameter("fileRoot");
            if (tempStr != null && !tempStr.equals("")) {
                fileRoot = tempStr;
            }
        }    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //String filepath = request.getParameter("filepath");
            String filepath = "test.txt";
            String fullFilePath = fileRoot + filepath;        File file = new File(fullFilePath);        if (file.exists()) {
                String filename = URLEncoder.encode(file.getName(), enc);
                response.reset();
                response.setContentType(contentType);
                response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
                int fileLength = (int) file.length();
                response.setContentLength(fileLength);            if (fileLength != 0) {                InputStream inStream = new FileInputStream(file);
                    byte[] buf = new byte[4096];                ServletOutputStream servletOS = response.getOutputStream();
                    int readLength;
                    while (((readLength = inStream.read(buf)) != -1)) {
                        servletOS.write(buf, 0, readLength);
                    }
                    inStream.close();
                    servletOS.flush();
                    servletOS.close();
                }
          }
    }
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
    }
    }
      

  6.   

    Orilly 和 Apache都有相应的包,网上搜索一下很多的。