<% @ Page ContentType = "text / html; charset = GBK"%> <% @ page import = "java.io. *"%> <% // The relative path where the current file is located in servlet and JSP and absolute The absolute path corresponding to the root directory: " Request.getRequesturi () " 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 (request.getRealpath)). getParent (); out.println (" Directory absolute path : " STRDIRPATH "
");%> // servlets // jsp APLICATION object is ServerContext in the servlet, so this is thus obtained in the servlet // import java.io.file; system.out.println (" The root directory corresponds to Absolute path: " Request.getServletPath () "
"); String strpathfile = request.getSession (). GetServletContext (). GetRealPath (Request.getRequesturi ()); System.out.Println (" File absolute path: " strpathfile "
"); String strdirPath = new file (Request.getSession (). GetRealPath ())). GetParent (); system.out.println (" Directory absolute path: " strDirPath "
"); The file name cannot include the following characters: //: *?" <> |