CGI CS422 Dick Steflik.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
Advertisements

Forms Describe common uses of forms on web pages
Python and Web Programming
Definitions, Definitions, Definitions Lead to Understanding.
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.
Using Entities & Creating Forms Jill R. Sommer Institute for Applied Linguistics Kent State University.
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.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
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,
Web Application Programming Carol Wolf Computer Science.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
USING PERL FOR CGI PROGRAMMING
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
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.
Chapter 6 Server-side Programming: Java Servlets
Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
Perl: Lecture 2 Advanced RE & CGI. Regular Expressions 2.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Form Data Encoding GET – URL encoded POST – URL encoded
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
Shellshock a.k.a. Bashdoor / Bash bug
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
 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.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
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)
National College of Science & Information Technology.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
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.
Introduction to Internet Programming (Web Based Application)
Shellshock a.k.a. Bashdoor / Bash bug
Section 6.3 Server-side Scripting
WWW and HTTP King Fahd University of Petroleum & Minerals
The Hypertext Transfer Protocol
Web Development Web Servers.
How does it work ?.
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
Hypertext Transport Protocol
CSN09101 Networked Services Week 10: Using Apache
PHP / MySQL Introduction
#05 Web Server (CGI, Node.js)
Web App vs Mobile App.
Dr. John P. Abraham Professor UTRGV eCommerce CSCI 6314
Chapter 27 WWW and HTTP.
CS320 Web and Internet Programming Cookies and Session Tracking
CS3220 Web and Internet Programming Cookies and Session Tracking
Session Tracking Techniques
World Wide Web Uniform Resource Locator hostname [:port]/path
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol
Back end Development CS Programming Languages for Web Applications
CS3220 Web and Internet Programming Cookies and Session Tracking
An Example of a TCP/IP Application: the World Wide Web
Shellshock a.k.a. Bashdoor / Bash bug
Back end Development CS Programming Languages for Web Applications
MSc Internet Computing
Presentation transcript:

CGI CS422 Dick Steflik

Common Gateway Interface "Old School" Basis for all of the current ways of making Web Apps Php ASP JSP Java Servlets

CGI Commonly used languages PERL Python Ruby

CGI Provides a mechanism for a browser to request a web server to run a local program that will provide the body of an HTTP response packet The request is in the form of an HTTP request packet and can be a GET or POST

Environment Variables CGI specifies a set of Environment Variables that are created from a combination of: the servers runtime environment information from the header of the browser's request packet

COMSPEC="C:\Windows\system32\cmd.exe" DOCUMENT_ROOT="C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs" GATEWAY_INTERFACE="CGI/1.1" HOME="/home/SYSTEM" HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7" HTTP_ACCEPT_ENCODING="gzip, deflate" HTTP_ACCEPT_LANGUAGE="en-us,en;q=0.5" HTTP_CONNECTION="keep-alive" HTTP_HOST="example.com" HTTP_USER_AGENT="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0" PATH="/home/SYSTEM/bin:/bin:/cygdrive/c/progra~2/php:/cygdrive/c/windows/system32:..." PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" PATH_INFO="/foo/bar" PATH_TRANSLATED="C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\foo\bar" QUERY_STRING="var1=value1&var2=with%20percent%20encoding" REMOTE_ADDR="127.0.0.1" REMOTE_PORT="63555" REQUEST_METHOD="GET" REQUEST_URI="/cgi-bin/printenv.pl/foo/bar?var1=value1&var2=with%20percent%20encoding" SCRIPT_FILENAME="C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin/printenv.pl" SCRIPT_NAME="/cgi-bin/printenv.pl" SERVER_ADDR="127.0.0.1" SERVER_ADMIN="(server admin's email address)" SERVER_NAME="127.0.0.1" SERVER_PORT="80" SERVER_PROTOCOL="HTTP/1.1" SERVER_SIGNATURE="" SERVER_SOFTWARE="Apache/2.2.19 (Win32) PHP/5.2.17" SYSTEMROOT="C:\Windows" TERM="cygwin" WINDIR="C:\Windows"

timeline user clicks "Submit" on web page Browser builds an HTTP request packet HTTP method is from <form> tag method attribute if method is GET data is added on to URL as Query_String if method is POST data (name value pairs) are put into the request packet body as URL encoded data CGI is from <form> action attribute) HTTP_User_Agent is set by the browser TCP connection is made to port 80 on server from a random high numbered port on the client and request packet is sent to server Server blocks port 80 and transfers to a random high numbered port to process the request packet then unblocks port 80 The server processes the request

timeline (cont.) server processing packet is received body goes to SYSIN info is taken from the request header and moved into environment variables if HTTP method is GET is the requested resource a CGI then run the CGI get data from QUERY_STRING build the response packet (set Content-type to text/html) else retrieve the resource if HTTP method is POST run the CGI read the data from SYSIN send the response packet close the TCP connection

name/value data depending on the CGI language the name/value data is handeled differently python name/values are consumed from SYSIN or QUERY_STRING and moved to a Python dictionary called FieldStorage() and can be retrieved via getvalue() perl usually moves the name/value pairs from SYSIN or QUERY_STRING into a buffer and then splits them into an associative array java usually has library support to put it into a hash table

State in a Stateless Environment program state in the HTTP stateless environment must be maintained by coordinating the browser and the CGI one way is by hiding state variables in the HTML form by using hidden fields modified by the CGI to reflect state <input name= something type=hidden /> another way is by using cookies in the response header or a combination of the two