250 likes | 348 Views
Chapter 3 Web Software. Objectives. Name the four primary components of a web-based application Describe the responsibilities of a web browser Explain cache control and cookie management details Describe the responsibilities of a web server
E N D
Objectives • Name the four primary components of a web-based application • Describe the responsibilities of a web browser • Explain cache control and cookie management details • Describe the responsibilities of a web server • Explain the different web development application environments • Describe the purpose of an RDBMS • Name the protocols supported by a modern RDBMS
Web Application Components • Four important components of a web application: Business Application Web Browser Web Server Database Server Client-Side Server-Side
Web Application Components • Web Browser: presents the user interface • Web Server: processes HTTP requests • Business Application: processes requests at the application level by providing a service • Database Server: maintains the database by processing query and update requests from the application
Web Browser Responsibilities • User Interface Presentation • Client-Server Communication (HTTP) • Cache Control • Cookie Management • Handling Embedded Objects • Script Interpretation
User Interface Presentation • Parse HTML and CSS code • handle errors • Format and present a graphical display • Handle user interactions • scroll, mouse movement, click, etc.
Client-Server Communication (HTTP) • Format HTTP request • Handle HTTP response • including redirects, errors, etc. • Request subordinate items • images, style sheets, etc.
Cache Control • Cache is a local memory for recently accessed web pages, images, etc. • Cache enables pages to be reloaded quickly, without another HTTP transaction Cache reload Server Browser initial request
Cache Control HTTP Headers • Cache-Control: <option> (response header) • public – client or proxy server may cache • private – only the client may cache • no-cache – no caching anywhere • If-Modified-Since: <date> (request header) • tells server to send resource only if modified since the specified date • otherwise the client will use a cached version
Cache Control HTTP Headers • HTTP response with Cache-Control header HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Last-Modified: Thu, 22 Sep 2005 12:57:30 GMT Cache-Control: private Expires: Wed, 26 Sep 2007 14:15:51 GMT Content-Type: text/html Content-Length: 327 Date: Tue, 25 Sep 2007 14:15:51 GMT • HTTP transaction with If-Modified-Since header GET /index.html HTTP/1.1 Host: grove.cs.jmu.edu If-Modified-Since: Tue, 25 Sep 2007 14:15:51 GMT Date: Tue, 25 Sep 2007 14:15:51 GMT HTTP/1.1 304 Not Modified Date: Tue, 25 Sep 2007 14:35:36 GMT Server: Apache/2.2.3 (Red Hat) request response
Cookie Management • An HTTP cookie is a small file that is • provided by the server as an HTTP response header • stored by the client • returned to the server as an HTTP request header Server Client Cookie contents Cookie Storage
Cookies and Sessions • HTTP Session: a series of HTTP transactions between a client and a server • Cookies allow servers to identify sessions • Typical usage • initial transaction: server creates session (server-side) and stores session-id in a cookie (client-side) • subsequent transactions: client sends session-id with each request, allowing server to locate session data
Cookies and Sessions Server Client Make 1st request Create session Handle response Session data * Cookie (session-id) Make 2nd request * Continue session Handle response * includes session-id
Cookie Parameters • Cookie parameters are set in a Set-Cookie response header HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: domain=widget.com; path=/; secure; Account=766324 Content-Type: text/html Content-Length: 327 Date: Tue, 25 Sep 2007 14:15:51 GMT
Cookie Parameters • expires=<date>: determines when cookie will be deleted • domain=<domain name> : cookie will be returned to each domain that ends with this value • path=<path name> : cookie will be returned only for requests that start with this path • secure : if present, cookie will be returned only with HTTPS (secure HTTP) requests • <name>=<value> : allow arbitrary data to be stored in a cookie
Handling Embedded Objects • Objects referenced by an HTML document (images, scripts, style sheets, etc.) must be loaded separately by the browser • A plug-in or helper application may be used • Helper application: a program that handles content in a separate window • e.g., audio player, movie player • Plug-in: a program that handles content within the browser • e.g., animation viewer or virtual machine for applets
Script Interpretation • Most browsers interpret JavaScript and its variants (ECMAScript, JScript, etc.) • Scripting languages are powerful, so interpreters are necessarily complex • Script interpreters are not entirely standardized across browsers, so script programmers must test scripts on many browser versions • The “write once, test many” principle in action
Web Server Responsibilities • Connection Management • HTTP request handling
Connection Management • With HTTP/1.1, servers are responsible for setting up and tearing down TCP connections over a series of requests • improves efficiency
HTTP Request Handling • Servers must correctly interpret HTTP request headers and respond appropriately • Static content includes fixed files that are returned without any further computation • Dynamic content is generated on request by an application component that is invoked by the server
Application Development Environments (1/2) • Common Gateway Interface (CGI) • allows programs to be invoked at the operating system level • Servlet Container • allows programs written in Java to be invoked in a Java Virtual Machine linked to the server
Application Development Environments (2/2) • Template Language • allows executable code to be inserted into an HTML document • Scripting Language • a language that can be used to generate HTML content on request • typically have relaxed syntax, requiring less coding than regular programming languages
Database Server Responsibilities • Relational Database Management System (RDBMS) • Maintains data storage for an application • processes queries and updates • Provides a standard interface for application programs • Open DataBase Connectivity (ODBC) • Java DataBase Connectivity (JDBC) • Supports standard query language for data query and manipulation • Structured Query Language (SQL)
Review • Web application components • Web browsers • Web servers • Application development environments • Database servers