<% String Path = Request.getcontextpath (); String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; %>
This statement is used to assemble the relative path of the current page.
<base href= "..." > is the root path used to indicate the relative path of the current page. For example, there is a connection inside the page, the complete path should be http://localhost:80/myblog/authen/login.do where http://server/is the basic path of the server, MyBlog is the name of the current application, My root path should be so http://localhost:80/myblog/.
With this <base ... > after the connection of my page content, I do not want to write the full path, I just write authen/login.do on it. The server will automatically assemble the path specified by <base ...> and the relative path within the page to form the full path. If there is no such <base...>, then the link of my page must write the full path, otherwise the server will not be found.
Request.getschema () can return the protocol used by the current page, or the "http" Request.getservername () in the example above can return the name of the server on which the current page is located, or "localhost" in the example above. Request.getserverport () can return the port used by the server on which the current page is located, that is, Request.getcontextpath () can return the name of the application where the current page is located, which is the myblog in the example above. Four assembled together is the path to the current application.
Thanks to the http://www.cnblogs.com/token/archive/2012/08/13/2636287.html author for sharing
Java EE page Get path