CP476 Internet Computing CGI1 CGI is a common way to provide for specific computations on server side, interactions with users, or access to databases.

Slides:



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

Web forms and CGI scripts Dr. Andrew C.R. Martin
Lecture 11 Server Side Interaction
HyperText Markup Language (HTML). Introduction to HTML Hyper Text Markup Language HTML Example The structure of an HTML document Agenda.
Java Script Session1 INTRODUCTION.
Adding Dynamic Content to your Web Site
CGI Programming.
CGI Programming Part 2. Input Tags Many different ways of getting data from the user. The tag is used most often. has a type attribute –Specifies the.
CGI programming in Perl Learning Objectives: 1. To understand how a CGI program works in Perl and how to make it runnable in web browsers 2. To learn how.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Using Perl for CGI Programming
JavaScript Forms Form Validation Cookies CGI Programs.
 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.
COS 381 Day 20. Agenda  Assignment #5 Due  Capstone Progress Reports Overdue Were Due April 7  Capstone projects are DUE May 10 at 1PM  Assignment.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
CS 898N – Advanced World Wide Web Technologies Lecture 6: PERL and CGI Chin-Chih Chang
CGI Programming in Perl Software Tools. Lecture 22 / Slide 2 CGI Programming l Last time we looked at designing a static web page. Today we will see how.
CGI programming in Perl Learning Objectives: 1. To understand how a CGI program works in Perl and how to make it runnable in web browsers 2. To learn how.
COS 381 Day 23. Agenda  Questions??  Resources Source Code Available for examples in Text Book in Blackboard
Guide To UNIX Using Linux Third Edition
WWW and Internet The Internet Creation of the Web Languages for document description Active web pages.
COS 381 Day 23. Agenda  Questions??  Resources Source Code Available for examples in Text Book in Blackboard
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.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
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.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
Using Html Basics, Text and Links. Objectives  Develop a web page using HTML codes according to specifications and verify that it works prior to submitting.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
USING PERL FOR CGI PROGRAMMING
Java CGI Lecture notes by Theodoros Anagnostopoulos.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
CGI Programming. What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. CGI is not a Perl-specific concept. Almost.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Chapter 9: Perl and CGI Programming CGI Programming Acknowledgement: Some materials are taken from Teach Yourself CGI Programming with PERL 5 in a Week.
Chapter 6 Server-side Programming: Java Servlets
1 © Copyright 2000 Ethel Schuster The Web… in 15 minutes Ethel Schuster
Chapter 10 © 2003 by Addison Wesley Longman, Inc. 1 Chapter 10 Using Perl for CGI Programming.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
CSU - DEO Introduction to CGI - Fort Collins, CO Copyright © XTR Systems, LLC Introduction to the Common Gateway Interface (CGI) Instructor: Joseph DiVerdi,
TJ 3043 – Web Application Development HTML Form. 2.0 Forms - A form is the usual way information is gotten from a browser to a server - HTML has tags.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
 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.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
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.
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)
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
Chapter 5 © 2002 by Addison Wesley Longman, Inc. 1 Chapter 5 Sebesta: Programming the World Wide Web.
Internet/Web Databases
Chapter 7 - Introduction to Common Gateway Interface (CGI)
CGI I: Basics Web Programming.
Florida Gulf Coast University
Chapter 27 WWW and HTTP.
10.1 The Common Gateway Interface
CGI I: Basics Web Programming.
Presentation transcript:

CP476 Internet Computing CGI1 CGI is a common way to provide for specific computations on server side, interactions with users, or access to databases –CGI is an interface between browsers and servers –It allows browsers to request the execution of server-resident software through form submission Servers can recognize such requests by the location of the requested file (special subdirectories for such files), or a server can be configured to recognize executable files by their file name extensions The parameter is stored in the environment hash of the connection –A CGI program can produce a complete HTTP response, or just the URL of an existing document Lecture 12. Common Gateway Interface ( CGI) Objective: to learn how to use CGI to request a computation on the server side, and to return the result to the requested browser.

CP476 Internet Computing CGI2 CGI Linkage –CGI programs often are stored in a directory named cgi-bin –A CGI program must be executable by one call exe file, compiled from C, java source code Perl programs are usually kept in source A source file can be made to be “executable” by adding a line at their beginning that specifies that a language processing program be run on them first –For Perl programs, if the perl system is stored in /usr/local/bin/perl, this is #!/usr/local/bin/perl –w An HTML document can specify a CGI program with the hypertext reference attribute, href, of an anchor tag,, as in <a href = " Click here to execute the cgi program reply.pl.

CP476 Internet Computing CGI3 #!/usr/local/bin/perl # reply.pl – a CGI program that returns a # greeting to the user print "Content-type: text/html \n\n", " \n", " reply.pl example ", " \n", " \n", " Greetings from your Web server!", " \n \n"; The connection from a CGI program back to the requesting browser is through standard output, usually through the server –The HTTP header needs only the content type, followed by a blank line, as is created with: –print "Content-type: text/html \n\n";

CP476 Internet Computing CGI4 Query String Format –A query string includes names and values of widgets –Widget values are always coded as strings –The form of a name/value pair in a query string is: name=value –If the form has more than one widget, their values are separated with ampersands & milk=2&payment=visa –Each special character is coded as a percent sign and a two-character hexadecimal number (the ASCII code for the character) –Some browsers code spaces a plus signs, rather than as %20

CP476 Internet Computing CGI5 The CGI.pm Module –A Perl module serves as a function library –The Perl use declaration is used to make a module available to a program –To make only part of a module available, specify the part name after a colon –use CGI ":standard"; Common CGI.pm Functions – “Shortcut” functions produce tags, using their parameters as attribute values e.g., h2("Very easy!"); is equivalent to Print “ Very eash! ”; produces Very easy! In this example, the parameter to the function h2 is used as the content of the tag

CP476 Internet Computing CGI6 Tags can have both content and attributes Each attribute is passed as a name/value pair, just as in a hash literal Attribute names are passed with a preceding dash textarea( -name => "Description", rows => "2“ cols => "35" ); Produces:

CP476 Internet Computing CGI7 –If both content and attributes are passed to a function, the attributes are specified in a hash literal as the first parameter a({-href => "fruit.html"}, "Press here for fruit descriptions"); Output: Press here for fruit descriptions –Tags and their attributes are distributed over the parameters of the function ol(li({-type => "square"}, ["milk", "bread", "cheese"])); Output: –CGI.pm also includes non-shortcut functions, which produce output for return to the user A call to header() produces: Content-type: text/html;charset=ISO blank line --

CP476 Internet Computing CGI8 The start_html function is used to create the head of the return document, as well as the tag The parameter to start_html is used as the title of the document start_html("Bill’s Bags"); <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml11-transitional.dtd"> <html xmlns= " lang="en-US"> Bill’s Bags The param function is given a widget’s name; it returns the widget’s value If the query string has name=Abraham in it param("name") will return "Abraham“ The end_html function generates