URL and URI differences and relative and absolute paths

Source: Internet
Author: User
Tags rfc

The concept of URLs and URIs has always been vague and has recently been encountered, taking this opportunity to delve deeper, including relative paths and absolute paths.


The graph lets you know that the URI (uniform Resource Identifier Uniform Resource Identifier) actually includes the URL (uniform Resource the Uniform Resource Locator) and the urn (Locator uniform Name The Uniform Resource name, which names the resource but does not specify how to locate the resource, and it can be said that the URI has one thing for both the locator and the name attributes. A URN acts like a person's name, and a URL is a person's address. In other words: The urn determines the identity of the thing, and the URL provides a way to find it.

Of course, now the main way to figure out the difference between URIs and URLs
is to first look at the Request.getrequesturi () and Request.getrequesturl () in the servlet in the Web project, respectively. The output URI and URL format are as follows
URI:/servlet3_exercise/login
Url:http://localhost:8080/servlet3_exercise/login at the highest level, A URI reference in the form of a string (abbreviated as "uri") syntax the following
[scheme:]scheme-specific-part[#fragment]
URI can be divided into opaque URLs and hierarchical URIs. The
opaque URI is an absolute URI, and its scheme-specific part does not start with a slash character ('/'). An opaque URI cannot be parsed further. Here are some examples of opaque URIs:
mailto:java-net@java.sun.com
News:comp.lang.java
urn:isbn:096139210x
Opaque URIs are rarely seen in Web projects, and you can learn about them. A hierarchical URI is either an absolute URI (its scheme-specific portion starts with a slash character) or a relative URI, which does not specify a scheme's URI . Below are some examples of layered URIs:
http://java.sun.com/j2se/1.3/(absolute URI)
/docs/guide/collections/designfaq.html#28 (relative URI)
DOCS/GUIDE/COLLECTIONS/DESIGNFAQ.HTML#28 (relative URI)
. /.. /.. /demo/jfc/swingset2/src/swingset2.java (relative URI)
File:///~/calendar (absolute URI) scheme:scheme-specific-part[# Fragment]
URL format can only be absolute, that is, must be in agreement: beginning. Someone may have seen a relative URL, but such a URL is not a strictly technical URL.

Finally, take a look at the examples from the authoritative RFC:

Ftp://ftp.is.co.za/rfc/rfc1808.txt (also a URL because of the Protocol)
Http://www.ietf.org/rfc/rfc2396.txt (also a URL because of the protocol)
Ldap://[2001:db8::7]/c=gb?objectclass?one (also a URL because of the protocol)
Mailt O:john.doe@example.com (also a URL because of the protocol)
News:comp.infosystems.www.servers.unix (also a URL becaus E of the Protocol)
tel:+1-816-555-1212
telnet://192.0.2.16:80/(also a URL because of the protocol)
Urn:o asis:names:specification:docbook:dtd:xml:4.1.2

These are all URIs, some of which are URLs, those that provide the access mechanism.

Reference: https://danielmiessler.com/study/url-uri/
Http://www.cnblogs.com/hust-ghtao/p/4724885.html
http://docs.oracle.com/javase/7/docs/api/

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.