In ASP, we can take directly to the absolute path of the current program where the current program is located (also called physical path).
However, in JSP, there is no direct method to get the absolute path of the current directory.
Request.getRealPath () just got the absolute path corresponding to the root directory, read the servlet API document, found that
Get the absolute path name of the current file in this way, such as writing this in my CQQ.JSP file:
<% String strabspath = Application.getRealPath (Request.getRequesturi ()); out.println (strabspath);%>
In fact, the Application object in JSP is ServerContext in servlet.
The path to this is d: /aaa/bb/ccc/cqq.jsp, if we don't want the file name behind,
That is, we want to get D: / AAA / BBB / CCC / this path, we can use the File class directly.
The complete statement should be like this:
String strabspath = new java.io.file (Application.getRealpath ())). GetParent ();