Overview A plain HTML document is static A CGI program is executed in real-time, so that it can output dynamic information. CGI (Common Gateway Interface)

Slides:



Advertisements
Similar presentations
CS 22: Enhanced Web Site Design - Week 8Slide 1 of 15 Enhanced Web Site Design Stanford University Continuing Studies CS 22 Mark Branom
Advertisements

CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
Adding Dynamic Content to your Web Site
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Common Gateway Interface (CGI). CGI is a protocol: CGI is not a programming language CGI is a protocol for the exchange of information between between.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
How does the server format the information it gives to the appln program? As environment variables and in standard input.
CGI. XML2 Common Gateway Interface n Georgia Tech 1995 Web Usage Survey –Perl % –C % –Shell Scripts - 8.1% –Tcl - Tool Commercial Language.
 2002 Prentice Hall. All rights reserved. 1 Chapter 6 – Introduction to the Common Gateway Interface (CGI) Outline 6.1 Introduction 6.2 Client and Web.
Outcomes Know what are CGI Environment Variables Know how to use environment variables How to process A simple Query Form Able to use URL Encoding rules.
Hypertext Transport Protocol CS Dick Steflik.
 What is it ? What is it ?  URI,URN,URL URI,URN,URL  HTTP – methods HTTP – methods  HTTP Request Packets HTTP Request Packets  HTTP Request Headers.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
CGI Programming Languages Web Based Software Development July 21, 2005 Song, JaeHa.
Common Gateway Interface
Ch27 - Common Gateway Interface (CGI) and Perl
INTRODUCTION TO WEB DATABASE PROGRAMMING
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Nic Shulver, Intro: Developing Server Applications What is a server? Many types of server – File server – file: networked file.
Web Server Design Week 14 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/14/10.
USING PERL FOR CGI PROGRAMMING
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
Java CGI Lecture notes by Theodoros Anagnostopoulos.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
CSCE Systems Programming Lecture 21 Web Server: CGI -Dynamic Pages CSCE March 25, 2013.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Website Development with PHP and MySQL Saving Data.
CGI Programming. What is it? CGI –Common Gateway Interface Standard way to pass information back to the Web Server –GET Query String –POST Standard Input.
1 Welcome to CSC 301 Web Programming Charles Frank.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Approaches for creating dynamic web pages Server-side processing: Server receives a request, performs all processing necessary to create a dynamic web.
Perl CGI What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. Perl have a *very* nice interface to create CGI.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Form Data Encoding GET – URL encoded POST – URL encoded
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Krerk Piromsopa. 1 Department of Computer Engineering. Chulalongkorn University. Web Application Generic Issues.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
Web Server Design Week 13 Old Dominion University Department of Computer Science CS 495/595 Spring 2012 Michael L. Nelson 04/03/12.
Web Server Design Week 15 Old Dominion University Department of Computer Science CS 495/595 Spring 2009 Michael L. Nelson 4/20/09.
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
The Common Gateway Interface (CGI) Pat Morin COMP2405.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Web Protocols and Practice
CSCE Systems Programming
Client side & Server side scripting
Chapter 27 WWW and HTTP.
Chapter 2 Interacting with the Customer
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol
Environment Variables
World Wide Web Components
Web Server Design Week 16 Old Dominion University
Presentation transcript:

Overview A plain HTML document is static A CGI program is executed in real-time, so that it can output dynamic information. CGI (Common Gateway Interface) is the language or protocol that the browser uses to communicate the data from the form to the web server. A standard for interfacing external applications with information servers, such as HTTP or Web servers.

When the user submits his/her answers on a form, the browser bundles them up and sends them to the web server, which passes them on to your CGI script/program for processing. –The web page itself does not process the data entered on the form. Neither does the web server. A CGI script/program is any program which knows how to read that bundle of data. –The script/program must build up and return the html source for a web page –Shell and Perl scripts are easier and are more commonly used for CGI scripts.

CGI specification Define how these data are passed from the server to the gateway program, and vice versa

Script Web server CGI program Client Form Relative Programs and Files

... CGI program: /cgi-bin/php.cgi Script program: /~jlwang/php/test.html... CGI program: /cgi-bin/pw.pl

Script Web server Client Form Window based Structures HTTPODBC.DLL

... Script program: test.idc

Most gateway program are Scripts C, perl, shell Execution speed is often not an important factor The slowest part is the resource end

Communication with gateway programs Client to Server –URL query string –Extra path information in the URL –Message body (in HTML Forms) Server to Gateway program –Command-line argument –Standard input –Environment variables Gateway program to Server –Standard output

Client to Server URL query string – –Pass the query string query_info to the server –The server launches the gateway program ex_prog and passes it the query string Extra path information in the URL – –/dir/file: extra path information –Pass information using environment variables Message body –HTTP POST method within HTML FORM –Pass information using standard I/O

Server to Gateway program Command-line argument –GET method within ISINDEX query Standard input –POST method Environment variables –Everything sent by the client, except POST data –The query string –The extra path information –The request header

Gateway program to Server Standard output –The only way that gateway programs can pass data to a client –Two parts A collection of server directives –Be used to compose the response header The data

CGI Environment Variables Server  CGI About the Server Request-Specific Variables About the user

Server  CGI The server uses command line arguments as well as environment variables. These environment variables are set when the server executes the gateway program.

About the Server SERVER_SOFTWARE –The name and version of the information server software answering the request (and running the gateway). Format: name/version SERVER_NAME –The server's hostname, DNS alias, or IP address as it would appear in self-referencing URLs. GATEWAY_INTERFACE –The revision of the CGI specification to which this server complies. Format: CGI/revision

Request-Specific Variables SERVER_PROTOCOL –The name and revision of the information protcol this request came in with. –Format: protocol/revision ( SERVER_PORT –The port number to which the request was sent. REQUEST_METHOD –The method with which the request was made. For HTTP, this is "GET", "HEAD", "POST", etc. PATH_INFO –The extra path information, as given by the client.

PATH_INFO –The extra path information, as given by the client. PATH_TRANSLATED –The server provides a translated version of PATH_INFO, which takes the path and does any virtual-to-physical mapping to it. – –(Assume the document root path:/home1/www/docs) PATH_INFO = /a/b/c PATH_TRANSLATED = /home1/www/docs/x/y/z SCRIPT_NAME –A virtual path to the script being executed, used for self-referencing URLs.

QUERY_STRING –The information which follows the ? in the URL which referenced this script. – –QUERY_STRING= mcu.edu.tw AUTH_TYPE –The protocol-specific authentication method used to validate the user.

REMOTE_USER –If the server supports user authentication, and the script is protected, this is the username they have authenticated as. REMOTE_IDENT –Remote user name retrieved from the server. Usage of this variable should be limited to logging only. CONTENT_TYPE –For queries which have attached information, such as HTTP POST and PUT, this is the content type of the data. CONTENT_LENGTH –The length of the said content as given by the client.

About the user HTTP_ACCEPT –The MIME types which the client will accept, as given by HTTP headers. –Format: type/subtype, type/subtype HTTP_USER_AGENT –The browser the client is using to send the request. –Format: software/version library/version. REMOTE_HOST –Domain name of the user REMOTE_ADDR –IP address of the user

CGI: Output Standard output –Document generated by the script –Instructions to the server Scripts return –Output a document to their standard output –Output the location of the result document (either a full URL or a local virtual path) The server normally adds the needed HTTP headers to the back-end's results

Data stream –Header One or more lines of text, and is separated from the body by a blank line –Body Contains MIME-conforming data whose content type must be reflected in the header The server does not interpret or modify the body in any way

CGI Output Example print <<EOT; Content-type: text/html Search Results Search Results EOT

Examples

CGI and Database

Gateway Program

Database Interface Gateway program transfers the received data into the database query, which then is passed to database interface. Database interface parses the received database query

Database Server Database interface passes the query to the database server After handling the query, the database server feed the query result back to the database interface

Local Database Server The database server and the Web server are in the same site

Remote Database Server (homogeneous)

Remote Database Server ( heterogeneous )

Third party model Database independent

Report 3 ASAP WebShow 1,3,4 CyberGo 5,7,8 9,10,11 EarthgTime 12,13,14 Crescendo ActiveX Control 31,32,33 EchoSpeech 34,35,36 EchoSpeech Real Time Broadcast 38,39,40 Koan ActiveX Control 41,43,44 MidPlug 45,46,47 RapidTransit Player 48,49,50 RealAudio Player 52,53,54 Shockwave Audio 55,56,57 ToolVox PlugIn 58,60,61 TrueSpeech PlugIn 62, 66 WebTracks PlugIn 67, 69 Surround Video 15,16,17 VDOLive Video 18,19,20 VivoActive Video 21,22,23 MhAVI Video 24,25,26 ActiveMovie Video 28, 29,30

Home1 Personal Home Page Home2 Calculator ( HTML Control ) Home3Transparency Show ( Multiple Frame ) Home4 Chess ( ActiveX ) Home5Credit Card ( VBScript ) Home6 Cookie (Cookie) Home7Student Query System (IDC) Home8Teaching Schedule Transformation (PERL) Report1 ActiveX-1 Report2 ActiveX-2 Report3 ActiveX-3 Report4ActiveX-4