If the address is http: // localhost: 8080/deviantart/test/myjsp. jsp
Request. getcontextpath ()/deviantart
Obtain the container context path, which is generally the relative path of the website (project name ). If it is the root directory, the return value is "".
Request. getservletpath ()/test/myjsp. jsp
Obtain the relative Servlet Path.
Request. getrequesturi ()/deviantart/test/myjsp. jsp
Obtain the Request Path.
Request. getrealpath ("") D: \ Program Files \ apache-Tomcat-6.0.16 \ webapps \ deviantart
Request. getrealpath ("/AAAA/BBBB") D: \ Program Files \ apache-Tomcat-6.0.16 \ webapps \ deviantart \ AAAA \ BBBB
Obtain the absolute path (not recommended ).
######################################## ################
Application. getcontextpath ()/deviantart
Application. getrealpath ("") D: \ Program Files \ apache-Tomcat-6.0.16 \ webapps \ deviantart
Application. getrealpath ("AA/BB") D: \ Program Files \ apache-Tomcat-6.0.16 \ webapps \ deviantart \ AA \ bb
Application. getrealpath (request. getservletpath ())
D: \ Program Files \ apache-Tomcat-6.0.16 \ webapps \ deviantart \ test \ myjsp. jsp
##################################### ####################
replaceall ("\\\\", "XXXX"); represents a "\"