request.getRealPath("相对路径");就可以得到绝对路径了。

解决方案 »

  1.   

    getRealPath(java.lang.String path) 
              Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.在servlet2.1开始,已经用ServletContext.getRealPath(java.lang.String)方法替换了。
      

  2.   

    新问题:
    在jsp中,ServletContext con = new ServletContext();
    编译说是不可实例化,应该如何实例化呢?
      

  3.   

    找到了,知道了,用session,thx cat!
      

  4.   

    在JSP中直接用application.getRealPath("/");就能得到你Web的根目录了