<% @ page contenttype = "text / html; charset = GBK"%>
<% @ Page Import = "java.io. *"%>
<%
/ / The relative path to the current file in Servlet and JSP and the absolute path
// jsp
Out.println ("" The absolute path corresponding to the root catalog: " Request.getRequesturi () " ");
String strpathfile = Application.getRealPath (Request.getRequesturi ());
OUT.PRINTLN ("" The absolute path of the file: " StrPathFile " ");
Out.println (Application.getRealPath));
String strdirPath = new file (Application.getRealpath (Request.getRequesturi ()))). GetParent ();
Out.println ("The absolute path of the directory:" STRDIRPATH "");
%>
// servlet
The Application object in // JSP is ServerContext in the servlet, so this is so good in servlet.
// Import java.io.file;
System.out.Println ("The absolute path corresponding to the root catalog:" Request.getServletPath () "");
String strpathfile = request.getSession (). GetServletContext (). GetRealPath ());
System.out.println ("The absolute path of the file:" StrPathFile ");
String strdirpath = new file (). GetServletContext (). GetRealPath ())). GetParent ();
System.out.println ("The absolute path of the directory:" STRDIRPATH "");
The file name cannot include the following characters: //: *? "<> |