search
HomeWeb Front-endHTML TutorialWhat is the difference between URL and URI?

What is the difference between URL and URI?

Sep 09, 2017 pm 01:12 PM
Whatthe difference

When I first learned the http protocol, I was confused by these two similar terms. I checked a lot of information and finally figured it out. (It’s still in English when looking for information, it’s reliable...).

There have been many technical debates, the most interesting of which is probably the question of what the web address should be called. This is usually the case: someone calls the content of the address bar "URL". At this time, some people get excited: "No! In fact, the URI was..."

The reaction to this kind of correction is usually There are also several situations where the petty person just thinks that this person should leave quickly, the calm person shrugs his shoulders and agrees, and the angry person just draws a knife and fights, okay?

As for this article, it only provides a simple summary of this. After all, you have to get down to the point of making fun of each other, right?

URI, URL, URN

As you can see from the picture above, there are three different concepts: URI, URL, and URN. When discussing such a problem, the best way is to go back to the starting point. Here we are in RFC 3986: Uniform Resource Identifier (URI): Generic Syntax collects some information:

"A Uniform Resource Identifier (URI) is a compact string used to identify abstract or physical resources."

"A URI can be further divided into a locator, a name, or both. The term "Uniform Resource Locator" (URL) is a subset of a URI that, in addition to identifying a resource, also provides a primary access to locating that resource Mechanism (such as its network "location") "

Then our omniscient Wikipedia digests this paragraph very well and describes it more vividly:

"URI can be divided into URL, URN, or something that has both locators and names properties. URN acts like a person's name, and URL acts like a person's address. In other words: URN determines the identity of something, and URL provides a way to find it. ”

We can get some conclusions from these descriptions:

First of all, URL is a type of URI (you can see it through that picture Bar). So if someone tells you that a URL is not a URI, he or she is wrong. But not all URIs are URLs. Just like butterflies can fly, but not all butterflies can fly. What do you want flies to think?

  • What makes a URI a URL is of course the "access mechanism" and "network location". e.g.

    http://

    or
  • ftp://
  • .

    URN is part of the unique identifier, which is a special name.

  • Let’s take a look at an example, which is also from an 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)

  • mailto:John.Doe@example.com (also a URL because of the protocol)

  • news:comp.infosystems.www.servers.unix (also a URL because of the protocol)

  • tel:+1-816-555-1212

  • telnet://192.0.2.16:80/ (also a URL because of the protocol)

  • urn:oasis:names:specification:docbook:dtd:xml:4.1.2

  • These are all URI, some of which are URLs. Which ones? Those that provide access mechanisms. Summary

  • It’s time to answer the question:

When we replace the web address Which one is more accurate, URI or URL?

Based on a lot of articles I've read, including RFCs, I'd say URIs are more accurate.

Don’t worry, I have my reasons:

The URI we often use is not a URL in the strict technical sense. For example: the file you need is at

files.hp.com

. This is a URI, but not a URL – the system may respond correctly to many protocols and ports.

#####3#### ##Get a browser access address information in Java###
3 request
    * request对象,tomcat根据http协议的请求的内容,将相应的数据封装到request对象中。
    * request和response必须是成对出现,先有的request,再有的response
    * 接口:javax.servlet.http.HttpServletRequest extends javax.servlet.ServletRequest
    * 实现类:tomcat实现,并在请求时,tomcat创建 。
    * 请求行
        * 入口:http://localhost:8080/day05/demo/pathRequestServlet?username=jack&password=1234
        * 请求方式
            request.getMethod();
        * 路径
            // * 请求资源路径
            // 1 获得servlet路径,web.xml配置的url-pattern【★★★】
            String servletPath = request.getServletPath();
            System.out.println(" 1 servletPath -->" + servletPath);  //--> /demo/pathRequestServlet

            //2 获得发布到tomcat时的项目名称【★★★】
            String contextPath = request.getContextPath();
            System.out.println(" 2 contextPath -->" + contextPath);  //--> /day05

            //3 获得请求行中的资源路径
            String requestURI = request.getRequestURI();
            System.out.println(" 3 requestURI -->" + requestURI);//-->/day05/demo/pathRequestServlet

            //4 获得请求URL(地址栏书写)
            String requestURL = request.getRequestURL().toString();
            System.out.println(" 4 requestURL -->" + requestURL);//-->http://localhost:8080/day05/demo/pathRequestServlet
            // *** 以上都不获得get请求的参数

            //5 获得get请求的参数,获得的是所有参数的一个字符串
            String queryString = request.getQueryString();
            System.out.println(" 5 queryString -->" + queryString); //-->username=jack&password=1234

        * 协议
            request.getProtocol();
    * 请求头
        * java.lang.String getHeader(java.lang.String name) 获得指定名称的头信息(一条)【★★★】
        * long getDateHeader(java.lang.String name) 获得特殊数据,时间
        * int getIntHeader(java.lang.String name) 获得特殊数据,整型
        * java.util.Enumeration getHeaderNames() 获得所有的请求头的名称
        * java.util.Enumeration getHeaders(java.lang.String name) 获得指定名称头的所有内容
        * 实例:防盗链,(不能直接访问 /refererTwoServlet)
    * 请求体
        * ServletInputStream getInputStream() 获得请求体的所有内容。(之后讲,文件上传)

    * 核心API
        * 属性操作
            * xxxAttribute (set / get / remove)  服务器端【★★★】
        * 获得参数
            * 获得浏览器 发送给 服务器端的参数(Parameter)
            * API【★★★】
                * 实例:url?username=jack&username=rose&username=tom&password=1234
                * getParameter(java.lang.String name) 获得指定参数的第一个值,如果数据不存在获得null 。
                    * 例如:getParameter("username") 获得 jack
                * java.lang.String[] getParameterValues(java.lang.String name) 获得指定参数的所有的值。
                    * 例如:getParameterValues("username") ,获得[jack,rose,tom]
                * java.util.Map<String,String[]> getParameterMap() 获得所有的内容,key 参数的名称 ,value 该参数的所有的值
                    * 例如:{username=[jack,rose,tom],password=[1234]}
            * 中文乱码
                * POST请求【★★★】
                    * 设置 setCharacterEncoding(java.lang.String env) ,设置字符编码
                * GET请求
                    * new String(username.getBytes("ISO-8859-1"), "字符集");

The above is the detailed content of What is the difference between URL and URI?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Is HTML easy to learn for beginners?Is HTML easy to learn for beginners?Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is an example of a starting tag in HTML?What is an example of a starting tag in HTML?Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.