20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.

Slides:



Advertisements
Similar presentations
Adding Dynamic Content to your Web Site
Advertisements

TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Kyung Hee University 1 1 Application Layer. 2 Kyung Hee University Position of Application Layer.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Layer 7- Application Layer
How the web works: HTTP and CGI explained
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
The World Wide Web and the Internet Dr Jim Briggs 1WUCM1.
1 Software Testing and Quality Assurance Lecture 32 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Definitions, Definitions, Definitions Lead to Understanding.
WWW and Internet The Internet Creation of the Web Languages for document description Active web pages.
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.
Web Client/Server Communication A290/A590, Fall /09/2014.
CGI Programming Languages Web Based Software Development July 21, 2005 Song, JaeHa.
1 ‘Dynamic’ Web Pages So far, we have developed ‘static’ web-pages, e.g., cv.html, repair.html and order.html. There is often a requirement to produce.
INTRODUCTION TO WEB DATABASE PROGRAMMING
CS 299 – Web Programming and Design CS299: Web Programming and Design Instructor: Dr. Fang (Daisy) Tang.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
Web Servers Web server software is a product that works with the operating system The server computer can run more than one software product such as .
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)
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Human-Computer Interface Course 5. ISPs and Internet connection.
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,
FTP (File Transfer Protocol) & Telnet
2013Dr. Ali Rodan 1 Handout 1 Fundamentals of the Internet.
1 HTML (Set Up Public Folder) Some material on these slides is taken directly from
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
ES Module 5 Uniform Resource Locators, Hypertext Transfer Protocol, & Common Gateway Interface.
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.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
TCP/IP Protocols Dr. Sharon Hall Perkins Applications World Wide Web(HTTP) Presented by.
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.
1 Welcome to CSC 301 Web Programming Charles Frank.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Creating Web Documents: How the Web works Client / Server Protocols Access methods Homework: Complete experiment & report on Discussion Forum.
CSU - DEO Introduction to CGI - Fort Collins, CO Copyright © XTR Systems, LLC Introduction to the Common Gateway Interface (CGI) Instructor: Joseph DiVerdi,
Form Data Encoding GET – URL encoded POST – URL encoded
World Wide Web “WWW”, "Web" or "W3". World Wide Web “WWW”, "Web" or "W3"
CSE 341, S. Tanimoto Lisp CGI - 1 Lisp CGI Programming for the Web Web servers can invoke Lisp to “intelligently” create web pages on the fly. We will.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Jan 2001C.Watters1 World Wide Web and E-Commerce Client Side Processing.
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
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Web Services. 2 Internet Collection of physically interconnected computers. Messages decomposed into packets. Packets transmitted from source to destination.
Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Computer Network Architecture Lecture 6: OSI Model Layers Examples 1 20/12/2012.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
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)
Internet and World Wide Web Introduction to the Internet.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
WWW and HTTP King Fahd University of Petroleum & Minerals
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 27 WWW and HTTP.
Introduction to Servlets
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
Presentation transcript:

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming Lecture 7: HTTP & CGI

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 2 Lecture 7: HTTP and CGI Today’s Topics Hypertext Transfer Protocol (HTTP) Common Gateway Interface (CGI)

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 3 Lecture 7: HTTP and CGI URLs and URIs Used interchangeably: –URL: Uniform Resource Locator –URI: Uniform Resource Identifier URLs can use one of many different protocols: –ftp://… –news://… – (our focus today: http URLs)

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 4 Lecture 7: HTTP and CGI Anatomy of a URL Examples: –Host –Port

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 5 Lecture 7: HTTP and CGI Anatomy of a URL Examples –Path –Search

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 6 Lecture 7: HTTP and CGI HTTP Client-Server Communication –The Browser is the Client –The Web Site is the Server Client Request: HTTP request Server Response: HTTP response

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 7 Lecture 7: HTTP and CGI HTTP Communication 1. Extract Host Part of URL 6. Render Response Browser 4. Send HTTP Request 5. Wait for Response GET /index.html Content/type: text/html Hello!... Hello! Get IP address from DNS 3. Establish TCP/IP connection to Host Web Server

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 8 Lecture 7: HTTP and CGI HTTP Is Stateless A stateless protocol doesn’t remember anything from one transaction to another (all transactions are independent) Workarounds: –Use INPUT with TYPE=HIDDEN to store state information –use cookies to store state information

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 9 Lecture 7: HTTP and CGI CGI: Common Gateway Interface Standard interface supports server programming in a variety of ways: –Unix shell scripts –PERL scripts –C, C++ programs –Java servlets –ASP –etc.

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 10 Lecture 7: HTTP and CGI CGI Protocol Browser Web Server CGI Program 1. Notice URL is a program 2. Prepare the environment 3. Launch script/program 6. Exit 7. Closes Connection 8. Display Content Hello! 4. Send Header Content-type: text/html 5. Send Content Hello!

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 11 Lecture 7: HTTP and CGI CGI Advantages Allows dynamic control of “pages” Examples: –counters –customized pages (user prefs) –interactions with state (server ‘remembers’ data from request to request; e.g., shopping basket)

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 12 Lecture 7: HTTP and CGI CGI Pitfalls Resource Requirements Resource Contention Where to Store Scripts? –Stored in one directory, managed centrally –Stored in several directories, distributed management

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 13 Lecture 7: HTTP and CGI CGI Pitfalls Portability –Yes: Perl, C, C++ –No: VBasic, Unix shell scripts Server Independence –File paths (data) –Program location (support functions)

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 14 Lecture 7: HTTP and CGI CGI Methods GET: Information is sent directly in the URL POST: Information is sent via STDIN stream

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 15 Lecture 7: HTTP and CGI CGI Variables REQUEST_METHOD: GET | POST QUERY_STRING: the data sent CONTENT_LENGTH: the amount of data If you use a CGI support library (e.g., CGI.pm), this is taken care of automatically

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 16 Lecture 7: HTTP and CGI Standard Variables See list on p. 875 of the text Try the mirror.cgi program on the course servermirror.cgi

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 17 Lecture 7: HTTP and CGI URL Encoding Special chars (&, +) must be escaped –‘&’ = %25; ‘ ’ = %20 CONTENT_TYPE indicates the style of encoding If you use a CGI support library, this is taken care of for you Example: basket.cgi with GET

20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 18 Lecture 7: HTTP and CGI Complete Example Simple Shopping Basket See script basket.cgi on the course serverbasket.cgi