A Web server responds to client (e.g., Web browser) requests by providing resources (e.g., XHTML documents).
Hypertext Transfer Protocol (HTTP) is a platform-independent protocol for transferring requests and files over the Internet (i.e., between Web servers and Web browsers).
HTTP defines several request types (also known as request methods), each of which specifies how a client sends a requests to a server.
The two most common HTTP request types are get and post. These request types retrieve and send client form data from and to a Web server.
A form is an XHTML element that may contain text fields, radio buttons, check boxes and other graphical user interface components that allow users to enter and submit data into a Web page.
A get request gets (or retrieves) information from a server. Such requests often retrieve an HTML document or an image.
A post request posts (or sends) data to a server, such as authentication information or data from a form that gathers user input.
Usually, post requests are used to post a message to a news group or a discussion forum, pass user input to a data-handling process and store or update the data on a server.
An HTTP request often sends data to a server-side form handlera program that resides on the Web server and is created by a server-side programmer to handle client requests.
Browsers often cache (i.e., save on a local disk) Web pages for quick reloading, to reduce the amount of data that the browser needs to download over the Internet.
A Web server is part of a multitier application, sometimes referred to as an n-tier application.
Multitier applications divide functionality into separate tiers (i.e., logical groupings of functionality). Tiers can be located on the same computer or on separate computers.
The information tier (also called the data tier or the bottom tier) maintains data for the application. The information tier typically stores data in a relational database management system (RDBMS).
The middle tier (also called the business logic tier) implements business logic to control interactions between application clients and application data.
Business logic in the middle tier enforces business rules and ensures that data is reliable before updating the database or presenting data to a user.
The client tier, or top tier, is the application's user interface.
Users can request documents from local Web servers (i.e., ones residing on users' machines) or remote Web servers (i.e., ones residing on machines across a network).
Local Web servers can be accessed in two ways: through the machine name, or through localhosta host name that references the local machine.
A host is a computer that stores and maintains resources, such as Web pages, databases and multimedia files.
A domain represents a group of hosts on the Internet.
Each domain has a domain name, also known as a Web address, which uniquely identifies the location of a business or organization on the Internet.
A fully qualified domain name (FQDN), also known as the machine name, contains a host (for example, www for World Wide Web) and a domain name, including a top-level domain (TLD).
The top-level domain is the last and most significant component of a fully qualified domain name.
Each FQDN corresponds to a numeric address called an IP (Internet Protocol) address, which is much like the street address of a house.
A Domain Name System (DNS) server is a computer that maintains a database of FQDNs and their corresponding IP addresses. The process of translating FQDNs to IP addresses is called a DNS lookup.
In the Apache HTTP server directory structure, XHTML documents must be saved in the htdocs directory.
The Common Gateway Interface (CGI) is a standard protocol for enabling applications (commonly called CGI programs or CGI scripts) to interact with Web servers and (indirectly) with clients (e.g., Web browsers).
CGI is often used to generate dynamic Web content using client input, databases and other information services.
A Web page is dynamic if its content is generated programmatically when the page is requested, unlike static Web content, which is not generated programmatically when the page is requested (i.e., the page already exists before the request is made).
HTTP describes a set of methods and headers that allows clients and servers to interact and exchange information in a uniform and predictable way.
An XHTML document is a plain text file that contains markings (markup or elements) that describe the structure of the data the document contains.
XHTML documents also can contain hypertext information (usually called hyperlinks), which are links to other Web pages or to other locations on the same page.
A URL contains the protocol of the resource (such as http), the machine name or IP address for the resource and the name (including the path) of the resource.
The HTTP get method indicates the client wishes to retrieve a resource.
The information in the Content-Type header identifies the MIME (Multipurpose Internet Mail Extensions) type of the content.
Each type of data sent from the server has a MIME type by which the browser determines how to process the data it receives.
It is possible to redirect (or pipe) standard output to another destination.
Function time gets the current time, which is represented as the number of seconds elapsed since midnight January 1, 1970, and stores the retrieved value to the location specified by the parameter.
C++ library function localtime, when passed a time_t variable, returns a pointer to an object containing the "broken-down" local time (i.e., days, hours, etc. are placed in individual object members).
Function asctime, which takes a pointer to an object containing "broken-down" time, returns a string such as Wed Oct 31 13:10:37 2004.
Environment variables contain information about the client and server environment, such as the type of Web browser being used and the location of the document on the server.
The value associated with an environment variable can be obtained by calling function getenv of <cstdlib> and passing it the name of the environment variable.
The QUERY_STRING environment variable contains information that is appended to a URL in a get request.
The form element encloses an XHTML form and generally takes two attributes. The first is action, which specifies the server resource to execute when the user submits the form. The second is method, which identifies the type of HTTP request (i.e., get or post) to use when the browser submits the form to the Web server.
The post method sets the environment variable CONTENT_LENGTH, to indicate the number of characters of data that were sent in a post request.
Function atoi of <cstdlib> can be used to convert the value contained in CONTENT_LENGTH to an integer.
The Refresh header redirects the client to a new location after a specified amount of time.
The Location header redirects the client to a new location.
The Status header instructs the server to output a specified status header line (such as HTTP/1.1 200 OK).
Cookies are essentially small text files that a Web server sends to your browser, which then saves them on your computer. Cookies are sent by the browser back to the server with each subsequent request to the same path until the cookies expire or are deleted.
The Set-Cookie: header indicates that the browser should store the incoming data in a cookie.
The environment variable HTTP_COOKIE stores the client's cookies.
State information can be maintained using cookies or by creating server-side files (i.e., files that are located on the server or on the server's network).
Only someone with access and permission to change files on the server can do so.