Docsity

Understanding Dynamic Documents & Server Side Includes in Dynamic Web Servers, Slides of Computer Networks

Partial preview of the text

Download Understanding Dynamic Documents & Server Side Includes in Dynamic Web Servers and more Slides Computer Networks in PDF only on Docsity!

Lecture 5

Dynamic Web Servers

slides are modified from Dave Hollinger Docsity.com

Web Server

  • Talks HTTP
  • Looks at METHOD, URI to determine what the client wants.
  • For GET, URI often is just the path of a file
    • relative to some directory on the web server

Dynamic Web Servers (^) Docsity.com 2

Dynamic Documents

  • Dynamic Documents can provide:
    • automation of web site maintenance
    • customized advertising
    • database access
    • shopping carts
    • date and time service
    • …

Dynamic Web Servers (^) Docsity.com 4

Web Programming

  • Writing programs that create dynamic documents has become very important
  • There are a number of general approaches:
    • Create custom server for each service desired
      • Each is available on different port.
    • Develop a real smart web server
      • Server Side Includes, scripting, server APIs
    • Have web server run external programs

Dynamic Web Servers (^) Docsity.com 5

Drawbacks to Custom Server Approach

  • We might have lots of ideas custom services
    • Each requires dedicated address (port)
    • Each needs to include:
      • basic TCP server code
      • parsing HTTP requests
      • error handling
      • headers
      • access control

Dynamic Web Servers (^) Docsity.com 7

Smart Web Server

  • Take a general purpose Web server (that can handle static documents) and - have it process requested documents as it sends them to the client
  • The documents could contain commands that the server understands - the server includes some kind of interpreter

Dynamic Web Servers (^) Docsity.com 8

Server Side Includes

  • Server Side Includes (SSI) provides a set of commands that a server will interpret
  • Typically the server is configured to look for commands only in specially marked documents - so normal documents aren’t slowed down
  • SSI commands are called directives
    • Directives are embedded in HTML comments

Dynamic Web Servers (^) Docsity.com 10

SSI Directives

  • A comment looks like this:
  • A directive looks like this:
  • SSI servers keep a number of useful things in environment variables: DOCUMENT_NAME, DOCUMENT_URL
  • echo : inserts the value of an environment variable into the page This page is located at

Dynamic Web Servers (^) Docsity.com 11

More Power

  • Some servers support elaborate scripting languages
  • Scripts are embedded in HTML documents, the server interprets the script: - Microsoft Active Server Pages (ASP) - JScript, VBScript, PerlScript - Netscape LiveWire - JavaScript, SQL connection library. - Many others…

Dynamic Web Servers (^) Docsity.com 13

Server Mapping and APIs

  • Some servers include a programming interface that allows to extend the capabilities of the server by writing modules
  • Specific URLs are mapped to specific modules instead of to files

Dynamic Web Servers (^) Docsity.com 14

Common Gateway Interface

  • CGI is a standard interface to external programs supported by most (if not all) web servers - CGI programs are often written in scripting languages (perl, tcl, etc.),
  • The interface that is defined by CGI includes:
    • Identification of the service (i.e.,external program)
    • Mechanism for passing the request to the external program Dynamic Web Servers (^) Docsity.com 16

Common Gateway Interface

  • CGI is a standard mechanism for:
    • Associating URLs with programs that can be run by a web server
    • A protocol (of sorts) for how the request is passed to the external program
    • How the external program sends the response to the client

CGI (^) Docsity.com 17

CGI URLs

  • There is mapping between URLs and CGI programs provided by a web sever - The exact mapping is not standardized - web server admin can set it up
  • Typically:
    • requests that start with /CGI-BIN/ , /cgi-bin/ or /cgi/, etc. - not to static documents

CGI (^) Docsity.com 19

HTTP Server - CGI Interaction

CGI 20

HTTP SERVER CGI Program

stdin

stdout

Environment Variables

Docsity.com