");
String strPathFile = application.getRealPath(request.getRequestURI());
out.println("文件的絕對路徑:" + strPathFile+ "
");
out.println(application.getRealPath(request.getRequestURI()));
String strDirPath = new File(application.getRealPath(request.getRequestURI())).getParent();
out.println("目錄的絕對路徑:" + strDirPath + "
");
%
//Servlet中
//JSP中的application對象就是Servlet中的ServerContext,所以在Servlet中是如此獲得
//import java.io.File;
System.out.println("根目錄所對應的絕對路徑:" + request.getServletPath() + "
");
String strPathFile = request.getSession().getServletContext().getRealPath(request.getRequestURI());
System.out.println("文件的絕對路徑:" + strPathFile + "
");
String strDirPath = new File(request.getSession().getServletContext().getRealPath(request.getRequestURI())).getParent();
System.out.println("目錄的絕對路徑:" + strDirPath + "
");
文件名不能包括以下字符:\/:*?"|