Approaches for creating dynamic web pages Server-side processing: Server receives a request, performs all processing necessary to create a dynamic web.

Slides:



Advertisements
Similar presentations
Chapter 25 Perl and CGI (Common Gateway Interface)
Advertisements

PHP I.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Languages for Dynamic Web Documents
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
JavaScript Forms Form Validation Cookies CGI Programs.
Introduction to Web Database Processing
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Introduction to Web Interface Technology (CSE2030)
CS 898N – Advanced World Wide Web Technologies Lecture 6: PERL and CGI Chin-Chih Chang
Introduction to Web Interface Technology (CSE2030)
Guide To UNIX Using Linux Third Edition
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.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Common Gateway Interface
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
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.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
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 PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
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)
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)
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
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,
Nic Shulver, Intro: Developing Server Applications What is a server? Many types of server – File server – file: networked file.
Hypertext Markup Language HTML Hypertext is vaguely defined as interconnecting pieces of information in a non-sequential but usually relational, manner.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
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.
Chapter 8 Cookies And Security JavaScript, Third Edition.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Form Data Encoding GET – URL encoded POST – URL encoded
Introduction to JavaScript CS101 Introduction to Computing.
Netprog 2002 CGI Programming1 CGI Programming CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
 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.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
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.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
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.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 CGI (Common Gateway Interface) CmpE 587 Emir Bayraktar Onur Bük.
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.
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.
CS 330 Class 7 Comments on Exam Programming plan for today:
Chapter 27 WWW and HTTP.
WEB PROGRAMMING JavaScript.
Presentation transcript:

Approaches for creating dynamic web pages Server-side processing: Server receives a request, performs all processing necessary to create a dynamic web page, sends the finished page to client for display. Client-side processing: Some processing is done on client side e.g validation, animation, changing colours, opening new windows etc.

Web Technologies Server-side processing Client-side processing CGI programs (Any language) Compiled Programs - ISAPI, NSAPI, Servelets Server side includes (SSI) Server-side scripts Shell, JavaScript, Perl, VBScript, Active Server Pages (ASP), Java server pages (JSP) Compiled Programs - Applets, ActiveX programs Using Document Object Model (DOM) with: JavaScript VBScript

Common Gateway Interface (CGI) How Web Server Works? Listening port - a daemon. Text commands from user agents. Example: GET index.html If index.html needs to display other files (e.g. images), the browser generates additional requests for each additional file and on receipt, combines them and displays. Example: Get /index.html Get /image1.gif Get /image2.gif

Web Server and CGI Browser sends requests that are implemented by server. HTTP protocol used by the web is mostly one way street. Bulk of data travels from server to the browser (text, graphics, sounds, applets, movies etc.). This is called Response path. Only a small amount of data flows in the other direction, called the Request path. Client Server

Where CGI fits in? Request path contains “Get” requests but some additional data also flows in this path: details about browser, user domain, and depending on method, data relating to fields in a form. When a server gets a request to run a CGI program, it collects the necessary data sent from the client, starts the CGI program and passes on the relevant data to it. There are two ways the data travels from the client to the server and then to the CGI program. GET method and POST method.

Understanding the Get Method In GET method, the data from the fields of a form are sent to the server as part of the URL. E.g. The text after ? Is the data meant for the CGI program (pgm1.cgi). The server packs the data in an environment variable called QUERY_STRING. Additional data about browser and its defaults are also packed in other environment variables that are made available to the CGI program. It is the job of the CGI program to separate the relevant data from environment variables and take required action. One of the ways to do that is to use Perl script to pick apart - “parse” individual pieces of information in QUERY_STRING. This information is in name = value pairs, each pair separated by &. ‘+’ is used for space and some other hexadecimal characters for control sequences.

Understanding the Post Method In this method no data is sent as part of the URL. All data is sent to the server via the requester path. Information from fields of a from is sent as name-value pairs. The server collects data in environment variables and the makes it available to the CGI program in the form of STDIN or standard input. It is the job of this program to parse the information contained in the standard input and use it as required. Some Environment variables: HTTP_ACCEPT: image/gif, image/jpeg (types of files that the browser can accept) HTTP_USER_AGENT: contains info about browser. QUERY_STRING: name=George&birthmonth=May REMOTE_ADDR, REQUEST_METHOD, SCRIPT_NAME, SERVER_PORT, etc.

Server Side Includes (SSI) Provide simple information as part of original page. Does not provide real interactivity. SSI directives are included in the HTML page, enclosed within comment tags The following formats are incorrect:

Server Side Includes (SSI) Some directives: CommandArgument #echovarDisplays the contents of environment variable. #fsizefileDisplays file size #flastmodfile When it was modified #execcmd Executes command cgi Executes cgi pgm. System administrators do not like to enable SSI on servers

Test page This page is to test working of SSI and Perl Your Browser is: Remote address is: (Last modified SSI Example

How to make web pages interactive? We discussed SSI. Server needs to know if it should go through a page requested by the browser or just send it without scanning. SHTML extension required for SSI. SSI do not make a page interactive. One of the common ways is to use Perl Script on server side. It is the job of this script to interpret if some information was received in the query string and get any required information, convert it to html and pass it to the server for onward transmission to the browser.

Introduction to Perl We shall look at two examples to have some idea of how Perl Script works. Like SSI, the browser needs to know if it should send the requested file without any further action or take some action. In this case to call perl program and pass info to it. Extension.pl required. First.pl forms.pl Your server does not have perl engine on it.

Perl was first released in 1987 Developed by Larry Wall Very powerful and elaborate textual pattern matching Most widely used language for CGI programming Need a Perl language processing system Perl has been ported to Many versions of UNIX and Windows. Introduction to Perl

Perl Variables Three categories: Scalar variables identified by '$' as first character of their names. Following the $, they must have at least one letter. Letters are case sensitive and by convention user-defined names are lower case. $name, $u3, $age etc. $age=35; #Assignment statement "Smith is $age years old" => "Smith is 35 years old" Can store 3 kinds of values: numbers, strings and references. Not declared explicitly - compilers declares implicitly when it first encounters it. (except local variables inside a function) Keyboard input: $input = Built-in functions: chomp($input = )

Perl has a number of predefined variables called the implicit variables often consisting of one or more special characters. E.g. underscore '_',circumflex '^' etc. It has usual control structures like: if, while, for, foreach etc. While (STDIN) { print; #what? chomp; #What is the argument to the function? if ($_ eq "yes") {print "Thanks for your consent"; } Array variables identified by as first character of their names. Hash variables identified by '%' as first character of their names. They are also called associative arrays. Perl Variables

pack function The web browser encodes special characters like !, *, ?,. Or \ etc. into the form %xx where xx is a pair of hexadecimal digits. The pack function uses a pattern 'C' to convert the number back to a character. (other patterns do exist). $ch = pack ("C", hex("2B")); Converts 2B into decimal 43 to character +. $ch = pack ("C", hex("21")); Converts 21 into decimal 33 to character !

Pattern Matching The pattern to be matched is delimited by slashes //. By default the string against which the matching is attempted is in the implicit variable $_. E.g: /k600/ tries to find k600 in the string contained in $_ /snow./ looks for strings starting with snow plus any other character at the end - snowy, snowe, snowd etc. You can specify a class of of characters for a match [abc] matches 'a', 'b', or 'c'. [a-h] matches any letter from 'a' to 'h'. '^' inverts the specified set e.g. [^aeiou] matches consonants only. Predefined character classes: \d, \D, \w, \s

Binding Operators If you want to match a pattern against a string contained in a variable other than $_ you need to bind that variable by using ~ operator. $string = ~ / \d/; looks for a digit in $string

Remembering Matches The part of a string that matched a part of a pattern can be saved for later use by placing parenthesis around the pattern. The sub-string that matches the first parenthesized part of the pattern is saved in a variable $1, the next in $2 and so on. "22 May 2002" =~ /(\d+) (\w+) (\d+)/; print "$2 $1, $3 \n"; Will print on the screen: May 22, 2002

Substitution A part of the string contained in $_ variable by default can be replaced by : s/Pattern/New_string/ $_ = "it is not raining today"; s/is not/ isn't/; In order to match a hexadecimal number one could use: /%[\dA-Fa-f]/ If we want to save the number found, we should use (): /%([\dA-Fa_f])/ The number found is saved in the implicit variable $1. We can convert it to a character by using pack function: pack("C", hex($1)); s/%([\dA-Fa_f])/pack("C", hex($1))/e;

Transliterate operator The operator "tr" translates a character or character class to another character or character class respectively. tr/;/:/; Translates all ; with : in $_. Note: the last ; is a statement terminator. tr/A-Z/a-z/; Converts all upper case letters to lower case letters.