Uri URL urn

Source: Internet
Author: User

First , the URI, which is the Uniform Resource identifier, is the Uniform Resource identifier used to uniquely identify a resource. The URL is a Uniform Resource Locator, a Uniform Resource locator, which is a specific URI that the URL can use to identify a resource and also how to locate the resource . and Urn,uniform resource Name, unified resource naming, is the name to identify resources, such as Mailto:[email protected]. That is, URIs define uniform resource identities in an abstract, high-level concept, whereas URLs and urns are specific resource identities. URLs and urns are all a kind of URI.

In the Java URI, a URI instance can represent absolute or relative, as long as it conforms to the syntax rules of the URI. The URL class not only conforms to semantics, but also contains information that locates the resource, so it cannot be relative, and the schema must be specified.

OK, now answer the questions raised at the beginning of the article, in the end is Imgurl good, or Imguri good? Obviously, if Imguri is definitely not a problem, because even if it is actually a URL, it is also a URI. So is there a problem with Imgurl? At this point to see its possible value, if it is an absolute path, can be positioned, then use Imgurl is not a problem, and if it is a relative path, that still do not use imgurl good. In short, with Imguri is sure no problem, and the use of Imgurl depends on the actual situation.

Second, as can be seen from HttpServletRequest's Javadoc, Getrequesturi returns a string, "the part of this request's URL from the protocol name The query string in the first line of the HTTP request ", such as" Post/some/path.html?a=b http/1.1 ", returns the value"/some/path.html ". Now you can see why Getrequesturi is not getrequesturl, because the relative path is returned here. And Getrequesturl returns a StringBuffer, "The returned URL contains a protocol, server name, port number, and server path, but it does Es not include query string parameters. ", complete request resource path, excluding querystring.

To summarize: A URL is a specific URI that uniquely identifies a resource and provides information to locate that resource. A URI is a semantic abstraction that can be absolute or relative, and the URL must provide enough information to locate it, so it is absolute, and the usual relative URL is for another absolute URL, which is essentially absolute.

Note: the absolute (absolute) here refers to the inclusion scheme, while the relative (relative) does not include scheme.

URI abstract Structure [scheme:]scheme-specific-part[#fragment]

[scheme:] [//Authority] [Path] [? Query] [#fragment]

authority for [user-info@]host[:Port]

Resources:

Http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URI.html

Http://en.wikipedia.org/wiki/Uniform_Resource_Identifier

Http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html


Source: >  

From for notes (Wiz)

Uri URL urn

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.