Unveiling the Web

6:28:00 AM |




How the Web Works
Before you learn how to write a very basicWeb page, you should understand a little about how the Web
works, such as what happens when you type aWeb address such as http://www.sciencezen.blogspot.com/ or
http://www.google.com/ into the browser and a page gets returned.
Every computer that is connected to the Internet is given a unique address made up of a series of four
numbers between 0 and 256 separated by periods—for example, 192.168.0.123 or 197.122.135.127. Thesenumbers are known as IP addresses. IP (or Internet Protocol) is the standard for how data is passed
between machines on the Internet.
When you connect to the Internet using an ISP you will be allocated an IP address, and you will often be
allocated a new IP address each time you connect.
EveryWeb site, meanwhile, sits on a computer known as a Web server (often you will see this shortened to
server). When you register a Web address, also known as a domain name, such as wrox.com you have to
specify the IP address of the computer that will host the site.
When you visit aWeb site, you are actually requesting pages from a machine at an IP address, but rather
than having to learn that computer’s 12-digit IP address, you use the site’s domain name, such as
google.com or wrox.com. When you enter something like http://www.google.com, the request
goes to one of many special computers on the Internet known as domain name servers (or name servers, for
short). These servers keep tables of machine names and their IP addresses, so when you type in
http://www.google.com, it gets translated into a number, which identifies the computers that serve
the GoogleWeb site to you.
When you want to view any page on the Web, you must initiate the activity by requesting a page
using your browser (if you do not specify a specific page, the Web server will usually send
a defaultWeb page). The browser asks a domain name server to translate the domain name you
requested into an IP address. The browser then sends a request to that server for the page you want,
using a standard called Hypertext Transfer Protocol or HTTP (hence the http:// you see at the start of
manyWeb addresses).
The server should constantly be connected to the Internet—ready to serve pages to visitors. When it
receives a request, it looks for the requested document and returns it. When a request is made, the server
usually logs the client’s IP address, the document requested, and the date and time it was requested.
An averageWeb page actually requires the Web browser to request more than one file from the
Web server—not just the XHTML page, but also any images, style sheets, and other resources in the
page. Each of these files, including the main page, needs a URL (a uniform resource locator) to
identify it. A URL is a unique address on the Web where that page, picture, or other resource can be
found and is made up of the domain name (for example, wrox.com), the name of the folder or
folders on the Web server that the file lives in (also known as directories on a server), and the name
of the file itself. For example, the Wrox logo on the home page of theWrox Web site has the unique
address wrox.com/images/mainLogo.gif and the main page is wrox.com/default.html. After
the browser acquires the files it then inserts the images and other resources in the appropriate place to
display the page.
The final chapter of the book covers putting your site on aWeb server, but first you must learn how to
build your site.
You may have noticed on the Web that Web pages do not always end in.html. There are lots of other
suffixes, such as .asp and .php. You are introduced to the languages ASP and PHP in the final chapter;
they usually run extra code on the server to generate a page especially for you. Meanwhile,.htm files are
just HTML files like those you have already started creating—because you can save HTML files with either
the suffix .htm or .html.
For an example of how all of this works, see Figure 1-1 and the explanation that follows it.



Figure 1-1
Here’s what’s going on in the figure:
1. A user enters a URL into a browser (for example, http://www.wrox.com). This request is
passed to a domain name server.
2. The domain name server returns an IP address for the server that hosts the Web site (for
example, 212.64.250.250).
3. The browser requests the page from theWeb server using the IP address specified by the domain
name server.
4. TheWeb server returns the page to the IP address specified by the browser requesting the page.
(The page may also contain links to other files on the same server, such as images, which the
browser will also request.)

0 comments: