Basepath in JSP (this article is reprinted articles, articles reprinted from http://blog.csdn.net/lutinghuan/article/details/6450174)
The following code is automatically generated on the new JSP page of Eclipse:
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>
The function generates the following path:
Path = webname; (current site name)
Basepath = http: // localhost: 8080/webname/
(Http: // localhost: 8080/webname/the most familiar address in the IE address view is generated in this way)
1. The advantage is that you can use absolute paths for the current link (absolute paths are also strongly recommended), such:
<A href = "<% = basepath %> index. jsp"> jump back to the home page </a>
2. The following code is automatically generated on the JSP page:
<Base href = "<% = basepath %>"/>
It specifies the default address of the current page as basepath, so
<A href = "index. jsp"> jump back to the home page </a>
The actual jump path is: http: // localhost: 8080/webname/index. jsp.