Thoughts on the role of basepath in JSP

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.