Monday, November 17, 2008

Web configurations: how the Web works

To access the Web, your computer (a Web client) will have to connect to another machine (a Web server) on the Internet via a network medium. For most home-based users, the Web server is usually a permanent machine on the Internet provided by the ISP and running server software. These systems may be a Microsoft NT system powered by the Internet Information Server (IIS) or UNIX (or LINUX) systems with Apache. Web browsers can be used to access millions of servers and get information by using the Hyper Text Transfer Protocol (HTTP). This process is sometimes called "The canonical browserserver interaction."

Typically, a Web client requests a document from a Web server through the HTTP command and a Uniform Resource Locator (URL). This occurs when the user types a Web address into the address field inside the browser. The server returns the document (usually in HTML format) and the browser displays that document in the browser window. This operation is generally referred to as Web.

The details of the browserserver dialog are not very important at this moment. The main task of the browser is to send the document request and the server is the machine that delivers the document. Consider the following command which you type in the address field of IE or NS:


http://www.abc.com/doc01.htm



This is one of the typical HTTP commands used to request the document doc01.htm from the www.abc.com site. A typical message that your browser will send to the server is





Listing: ex01-01.txt

1: GET /doc01.htm HTTP/1.0
2: Accept:www/source
3: Accept:text/html
4: Accept:image/gif
....
....
30: Accept:
31: User-Agent: ((Your browser software ID))
32: From: ((Your Email Address ID))
34: * a blank line *



For ease of reference, line numbers have been added to all listings in this book. The first line indicates which file the client wants and announces that the communication is HTTP version 1.0. This communication relies on the listed Accept elements in Multipurpose Internet Mail Extension (MIME) format. For example, in line 3, the text text/html means that the browser is expecting an HTML document in return. The blank line at the end identifies the end of the request.

The server, in this case www.abc.com, will then respond with a similar message like this:





Listing: ex01-02.txt

1: HTTP/1.0 200 OK
2: Date: Wednesday, 15-Oct-2003 13:04:12 GMT
3: Server: ((Your Server Information))
4: MIME-version: 1.0
5: Last-modified: Monday, 13-Oct-2003 11:33:16 GMT
6: Content-type: text/html
7: Content-length: 5312
8: * a blank line *
9: <'html><'head><'title>...<'/title><'/head><'body>...((etc))
(remove ' sign)


In line 1, the Web server agrees to use HTTP for communication and the status 200 indicates the successful completion of the whole request. After some HTTP system variables, Content-type: text/html in line 6 confirms that the document returned will indeed be an HTML document (or page). The entire HTML page will then be transmitted to the browser as illustrated in line 9. The entire dialog is specified by HTTP. The browser finally interprets this page and displays it on the screen. Again, the details of this dialog are not essential at this point.

This interaction or dialog set-up is important and considered as the foundation for all technologies between browsers and servers such as Perl, ASP, and PHP. A dialog like this will be discussed from time to time throughout this book when server technologies are introduced. At a minimum level, this dialog shows how and why a Web browser functions on the Web.

With the vast diversity of Web technologies we have today, the capabilities of browsers are far beyond the original HTML level. In order to gain a good grasp of the basic concepts, you can begin by designing some simple Web pages.

No comments: