Analysis of jsp method for obtaining url paths, jsp method for obtaining url paths
This example describes how to obtain the url path from jsp. We will share this with you for your reference. The details are as follows:
If the requested URL is http: // localhost: 8080/demo/Index. jsp
Request. getScheme () // output: httprequest. getServerName () // output: localhostrequest. getServerPort () // output: 8080request. getContextPath () // output:/demorequest. getRequestPath () // output:/Index. jsprequest. gerRequestURI () // output:/demo/Index. jsprequest. getRequestURL () // The output is http: // localhost: 8080/demo/Index. jsprequest. getRealPath ("") // output: D: \ apache-tomcat-6.0.10 \ webapps \ demo
I have verified the above several items, except that request. getRequestPath () cannot be used (it is estimated that this function has been deprecated). The other items are correctly displayed.
I hope this article will help you with JSP program design.