WT-Lec 2 Web Essentials: Clients, Servers, and Communication PDF
Document Details
Tags
Summary
This document discusses web clients and servers, including early browsers, modern browsers, and their functions. It also touches on the concept of HTTP URLs and user-controllable features in web browsers. The document appears to be lecture notes based on the title and content
Full Transcript
17/9/2024 LEC 2 Web Essentials: Clients, Servers, and Communicati...
17/9/2024 LEC 2 Web Essentials: Clients, Servers, and Communication 1 1 Web Clients Web Client: Software that accesses web servers via HTTP, including web browsers on various devices. User Agents: Web clients directly supporting user access, such as traditional browsers and web-crawling software robots. Traditional Browsers: Most widely used web clients with comprehensive features. Browser History: Early Browsers: Text-based or platform-specific. Mosaic: Introduced graphical web browsing in 1993. Netscape Navigator: Built on Mosaic, popularized browsing. Internet Explorer (IE): Microsoft’s dominant browser, bundled with Windows. 2 2 1 17/9/2024 Browser War: Competition between Netscape and Microsoft, ending with IE’s dominance and the launch of Mozilla as open-source. Modern Browsers: IE is still widely used; Mozilla/Firefox, Opera, and Safari also have significant user bases. Common Features: Modern browsers share basic user features and support HTTP communication. Mozilla Example: Platforms: Runs on Linux, Windows, and Mac. Open Source: Offers access to source code. Advantages: Developer tools and better standards compliance than IE. 3 Basic Browser Functions Browser Window Layout: A typical modern browser window is divided into several regions, primarily: Client Area: Displays the document. Title Bar: Shows the document title, browser name, and window controls. Menu Bar: Contains dropdown menus, similar to other GUI applications. Navigation Toolbar: Includes buttons like Back, Forward, Reload, Stop, and Print, along with a Location bar for entering URLs or performing searches. Status Bar: Displays messages and icons related to browser status, like connection status and communication security. 4 4 2 17/9/2024 Browser Tasks: Reformats a URL into an HTTP request. Uses DNS to resolve host names to IP addresses. Establishes a TCP connection with the web server. Sends the HTTP request and waits for the response. Displays and renders the document, positioning text and graphics in the browser window. 5 5 HTTP URL’s URL Components: Authority: The portion after "http://" and before the first slash, consisting of a domain name Path: The portion from the slash after the authority to the question mark, representing a file path on the server Query String: The portion between the question mark and the number sign, containing parameters Fragment: The portion after the number sign, used by browsers to scroll to a specific part of an HTML document. 6 6 3 17/9/2024 User-Controllable Features Save: Users can save web pages, including images and other embedded content, to their local file system. In Mozilla, this is done via File | Save Page As. Find in Page: Users can search text and HTML documents within the page using the Edit | Find in This Page option in Mozilla. It also offers a "find as you type" feature. Automatic Form Filling: The browser can save and automatically fill in form information like billing addresses. In Mozilla, use Edit | Save Form Info and Edit | Fill in Form. Manage saved forms via Tools | Form Manager. Document Meta-Information: Users can view details about the displayed document, including MIME type, encoding, size, and raw HTML source, via View | Page Source and View | Page Info in Mozilla. Themes: The appearance of the browser, particularly the navigation bar, can be changed using themes. In Mozilla, apply themes via View | Apply Theme. History: The browser keeps a list of recently visited pages, accessible in Mozilla through Go | History. 7 Bookmarks: Users can save URLs for easy access later. In Mozilla, use the Bookmarks menu to bookmark, access, and edit. 7 Preferences: Users can customize browser functionality, such as language preferences, character encoding, cache properties, and HTTP settings, through Edit | Preferences in Mozilla. Style Definition: Users can control how web pages are displayed, including font sizes and colors. In Mozilla, use View | Text Zoom and View | Use Style. 8 4 17/9/2024 Web Servers The primary function of a web server is to accept HTTP requests from web clients and return appropriate resources in the HTTP response. Here’s a breakdown of the key steps involved: 1.Listening for Connection Requests: The server uses TCP software to wait for connection requests on one or more ports. 2.Handling Connections: Upon receiving a connection request, the server assigns a "subtask" to handle the connection. 3.Establishing TCP Connection: The subtask establishes the TCP connection and receives the HTTP request from the client. 4.Determining the Virtual Host: The subtask examines the Host header field in the HTTP request to determine which "virtual host" should handle the request and invokes the appropriate software for this host. 5.Mapping Request-URI to Resource: The virtual host software maps the Request-URI field of the HTTP request start line to a resource on the server. 6.Returning a File Resource: If the resource is a file, the software determines its MIME type (usually based on the file-name extension) and creates an HTTP response with the file in the body of the response message. 9 9 7. Executing a Program: If the resource is a program, the software runs it, using information from the request, and returns the program's output as the body of an HTTP response message. 8.Logging the Request and Response: The server typically logs details about the request and response—such as the requester's IP address and the response status code—in a plain-text file. 9.Managing Persistent Connections: If the TCP connection is kept alive, the subtask continues to monitor it until a certain time elapses, the client sends another request, or the client initiates a connection close. Key Definitions: Subtask: Refers to the concept of a single "copy" of the server software handling a single client connection, enabling the server to process multiple requests concurrently. Virtual Host: A server that hosts multiple domain names on a single IP address. The Host header field in the HTTP request indicates which virtual host should handle the request. Dynamic Content Generation: Web servers often produce documents dynamically by executing software at the time of the HTTP request rather than serving pre-generated files. The support for executing various programming and scripting languages can vary between servers. 10 5 17/9/2024 Server History Apache Origin: Former httpd users created updates, called "patches," leading to the "Apache server." First Release: Apache was publicly released in April 1995 and became the most widely used server within a year. Microsoft IIS: Microsoft developed Internet Information Server (IIS) later but quickly caught up. IIS is limited to Windows, while Apache runs on Windows, Linux, and macOS. Programming Language Preferences: IIS: Often runs programs in VBScript (derived from Visual Basic). Apache: Commonly runs programs in Perl or PHP. Java Programs: Both IIS and Apache can run Java programs using a servlet container. Tomcat: Popular open-source servlet container by the Apache Software Foundation, capable of running as a standalone server. Tomcat Configuration: Often used for Java servlets, its configuration helps in understanding general server setups. 11 11 Server Configuration and Tuning External Communication : 1.IP Addresses & TCP Ports: Defines connection points for clients. 2.Number of Threads: Initial and maximum number of threads (TCP connections) allowed simultaneously. 3.TCP Connection Queue: Maximum number of queued requests if thread limit is reached. 4.Connection Timeout: Time the server waits before closing an inactive TCP connection. Internal Processing : 1.Client Access: Specifies which clients can send HTTP requests. 2.Virtual Hosts: Defines which virtual hosts listen on a specific port. 3.Logging: Configures request and response logging. 4.Request-URI Mapping: Maps the request path to server resources or file system. 5.Password Protection: Controls resource access through authentication. 12 6.Caching: Determines if resources are cached in server memory. 12 6 17/9/2024 Server Tuning: Adjusting parameters (like thread count or connection queue size) for performance optimization, often through trial and error. Tomcat Configuration: Web Interface: Accessible at http://localhost:8080. Components: JWSDP Service includes Connector, Host, Logger, Realm, and Valve. Connector: Key component managing HTTP communications, assigned to unique ports like 8080. Changes to configuration are saved and applied after committing and restarting the server. 13 13 Virtual Host Configuration (Tomcat Example) 1. Virtual Host Definition: A Host component represents a virtual host. It is usually a fully qualified domain name, e.g., www.example.org, but localhost is commonly used for local testing (loopback address 127.0.0.1). The Default Hostname setting (localhost in JWSDP) allows it to handle all HTTP requests if no other specific host is matched. 2.Adding New Virtual Hosts: Additional hosts can be created (e.g., www.example.org) to handle specific requests, while the default virtual host will handle all others. 3.Web Application Contexts: A Context within a Host represents a web application, defining the URL paths that map to specific directories or resources on the server. Predefined contexts (like /servlets-examples) come with the default localhost Host, mapping URL paths to directories in the server's file system. 14 14 7 17/9/2024 4. Application Base and Document Base: The Application Base defines the directory where the Host’s web applications are stored (relative to the server installation path). Each Context’s Document Base specifies the directory for its content (relative to the Application Base). 5.URL to Directory Mapping: URL paths (like /) are mapped to specific directories (e.g., /webapps/ROOT), where files like index.html are served as default welcome files. 6.Creating New Contexts: New contexts can be added by specifying a new Document Base (creating the directory before saving) and mapping URL paths accordingly. 15 Web Server Logs and Logging in Tomcat 16 8 17/9/2024 17 18 18 9