To reference the path of the current folder, I searched for a lot of information about the JSP path on the Internet and listed it one by one for reference:
The absolute path of the Directory, to the root directory folder of the Directory, such as the Project name: C:/program files/Apache Software Foundation/tomcat 5.5/webapps/projectname, there are two ways to get it:
1) application. getrealpath ("");
2) request. getrealpath ("");
The relative directory of the file name:
File name in the current directory folder: request. getservletpath (); for example:/users. jsp;
File name in the current project (root directory) folder: request. getrequesturi (); for example:/projectname/example. jsp;
Name of the current project (root directory) folder: request. getcontextpath (); for example:/projectname;
All folder names and file names in the current project folder are listed in the Data Group: application. getresourcepaths ("/");
For example: = [/Photo/,/Photo/,/check. JSP,/WEB-INF/,/foot. JSP,/center. JSP,/main. JSP,/data. JSP,/Contract/,/ctrl.htm,/send_check.jsp,/images/,/JS/,/user/,/META-INF/,/index. JSP,/CSS/,/left. JSP,/falsh/,/database/,/work/]
To obtain the current folder, you can use the character function to process it:
If you want to use the upload folder under the current folder (folder is the folder of my current file, and the current file name is upload. jsp:
C:/program files/Apache Software Foundation/tomcat 5.5/webapps/projectname/modules/upload
String parentpath = application. getrealpath (""). Replace ('//','/');
String pathname = request. getservletpath ();
Pathname = pathname. substring (0, pathname. lastindexof ('.'));
Parentpath + = pathname;
Having written so much, I feel that JSP cannot directly obtain the name of the current folder. It is quite uncomfortable to turn so many corners.