UNIFORM RESOURCE LOCATOR IN JAVA
Nadar saraswathi college of arts&science
UNIFORM RESOURCE LOCATOR
URL stands for Uniform Resource Locator is the
global address of documents and other
resources on the World Wide Web. Its main
purpose is to identify the location of a document
and other resources available on the internet,
and specify the mechanism for accessing it
through a web browser.
An example of a URL is
https://www.computerhope.com, which is
the URL for the Computer Hope website.
Overview of a URL.
A URL (Uniform Resource Locator) is a
unique identifier used to locate a resource
on the internet. It is also referred to as a
URLs consist of multiple parts including a
protocol and domain name that tell a web
browser how and where to retrieve a
The URL contains the name of the protocol
needed to access a resource, as well as a
COMPONENTS OF A URL
The protocol or scheme. Used to access a
resource on the internet. Protocols include http,
https, ftp, and file. The resource is reached
through the domain name system name. In this
example, the protocol is https.
Host name or domain name. The unique
reference the represents a webpage. For this
Port name. Usually not visible in URLs, but
necessary. Always following a colon, port 80 is
the default port for web servers, but there are
other options. For example, :port80.
Path. A path refers to a file or location on the
web server. For this example, search/query.
Query Found in the URL of dynamic page. The
query consists of a question mark, followed by
parameters. For this example, ?
Parameters Pieces of information in a query
string of a URL. Multiple parameters can be
separated by ampersands (&) For this example,
Fragment. This is an internal page reference,
which refers to a section within the webpage. It
appears at the end of a URL and begins with a
Note that the protocol identifier and the resource name
are separated by a colon and two forward slashes.
The protocol identifier indicates the name of the protocol
to be used to fetch the resource.
The example uses the Hypertext Transfer Protocol
(HTTP), which is typically used to serve up hypertext
documents. HTTP is just one of many different protocols
used to access different types of resources on the net.
Other protocols include File Transfer Protocol (FTP),
Gopher, File, and News.
The resource name is the complete address to the
The format of the resource name depends entirely on the
but for many protocols, including HTTP, the resource name
or more of the following components:
The name of the machine on which the resource lives.
The pathname to the file on the machine.
The port number to which to connect (typically optional).
For many protocols, the host name and the
filename are required, while the port number and
reference are optional.
For example, the resource name for an HTTP
URL must specify a server on the network (Host
Name) and the path to the document on that
It also can specify a port number and a
CONSTRUCTING A URL
The easiest way to create a URL object is from a
String that represents the human-readable form of
the URL address.
In your Java program, you can use a String
containing this text to create a URL object:
URL myURL = new URL("http://example.com/");
The URL object created above represents an
An absolute URL contains all of the information
necessary to reach the resource in question.
You can also create URL objects from a relative URL
A relative URL contains only enough information to
reach the resource relative to (or in the context of)
The URL is the address of a website. You can find it in
the address bar of your web browser. Alternatively, you
can find the URL for a link by right-clicking it and
copying the link
Your computer's URL code (or Internet address, or IP
address) is the address that other computers enter in
to access your computer across the Internet. This is a
four-section number, such as 123.456.78.90.
The URL (uniform resource locater) means the address
to something on the internet. It could be a webpage, file,
or a picture. In the case of Youtube, it is the address of
where a particular video is located