request.getRealPath("..\")
request.getRealPath("..\classes")

解决方案 »

  1.   

    request.getRealPath ("\WEB-INF");?
      

  2.   

    <%=request.getRealPath("\") %>
    <br>
    <%=request.getRealPath("..\classes") %>出错:
    Note: sun.tools.javac.Main has been deprecated.
    /test.jsp:47: String not terminated at end of line.
          out.print((request.getRealPath("\") ));
                                         ^
    /test.jsp:48: ')' expected.
          pageContext.write(_jsp_string3, 0, _jsp_string3.length);
    ^
    /test.jsp:49: Invalid escape character.
          out.print((request.getRealPath("..\classes") ));
                                            ^
    3 errors, 1 warning
      

  3.   

    还有一点,在servlet中怎么取?
      

  4.   

    in a servlet:
    //javax.servlet.ServletConfig config
    ServletContext context = config.getServletContext();
    System.out.println(context.getRealPath("/"));//output the webcontent directory
      

  5.   

    String requesturl=request.getRequestURI();
    String contextpath=request.getContextPath();
    String relativePath = requesturl.substring(contextpath.length());
    String filepath= getServletConfig().getServletContext().getRealPath(relativePath);另外request.getRealPath("")这方法已经不用了
      

  6.   

    To:  leowu(leo) cxjd(dong)   Webpath已经可以取到.   Classes 目录 怎么取到。
      

  7.   

    我知道: ServletContext context = config.getServletContext();
     System.out.println(context.getRealPath("/")) // 这个在Jsp和servlet中都可以用,JSP中把system.去掉。
      classpath:  String s=System.getProperty("java.class.path");