Web Server Programming: CGI(Perl/Python)

Slides:



Advertisements
Similar presentations
Languages for Dynamic Web Documents
Advertisements

DT211/3 Internet Application Development Active Server Pages & IIS Web server.
Server-Side vs. Client-Side Scripting Languages
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
Servlets and a little bit of Web Services Russell Beale.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
DT211/3 Internet Development Application Internet Development Application.
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.
Introduction to Web Interface Technology (CSE2030)
Multiple Tiers in Action
Python and Web Programming
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
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.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 24 – Web Servers (PWS, IIS, Apache, Jigsaw) Outline 24.1Introduction 24.2Microsoft Personal.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
HTML Hyper Text Markup Language A simple introduction.
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
Chapter 6 Server-side Programming: Java Servlets
Java Portals and Portlets Submitted By: Rashi Chopra CIS 764 Fall 2007 Rashi Chopra.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
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.
Java Server Pages Can web pages be created specially for each user?
CS299: Web Programming and Design Instructor: Dr. Fang (Daisy) Tang
Web Pages & Web Programming
Chapter 5 Scripting Language
WWW and HTTP King Fahd University of Petroleum & Minerals
Active Server Pages Computer Science 40S.
Warm Handshake with Websites, Servers and Web Servers:
E-business (constructed by Dr. Hanh Pham)
E-business (constructed by Dr. Hanh Pham)
Web Design Web Programming HTTP
Web Software Model CS 4640 Programming Languages for Web Applications
Introduction to E-business
Introduction to Programming the WWW I
Chapter 5 Scripting Language
PHP / MySQL Introduction
HTML Embedding, Tables and Forms
Part 2 Setting up a web server the easy way
Chapter 27 WWW and HTTP.
Java Servlet Ziad A. Al-Sharif.
Introduction to Servlets
Part 2 Setting up a web server the easy way
Client Side programming: Javascript, Cookies
Web Application Development Using PHP
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

Web Server Programming: CGI(Perl/Python) Slide # 07 Web Server Programming: CGI(Perl/Python) E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) Outline Server Programming Mechanisms Servlets CGI CGI with Python CGI with Perl CGI for Shopping Cart E-business (constructed by Dr. Hanh Pham)

Overview of Tools for Web Programming E-business (constructed by Dr. Hanh Pham)

Mechanisms for Web Server Programming Single-tenant: CGI (with Perl, PHP, Ruby, WebDNA, ASP, ColdFusion, … ) Multiple-tenant (shared virtual machine): Servlets (Java program, more for processing data, outputs HTML) JSP (HTML-like syntax and compiled into Servlet, more for presenting data) ASP.NET … E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) Java Servlets Servlet = a Java program which implement applications at a web server. Functions/Purpose: Process and store data (submitted from an HTML form) Provide dynamic content (results of a database query) Manage state information (exp: adding items to the shopping cart of the appropriate customer) Mechanism (How ?): When a request is made (via a JSP) a servlet is generated and deployed/ran within a web/servlet container. The web container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights. The servlet/object receives a request and generates a response based on that request. Servlets typically embed HTML inside Java code and generate HTML (to send to the browser). E-business (constructed by Dr. Hanh Pham)

Java Servlets in Details E-business (constructed by Dr. Hanh Pham)

Java Servlets with JSP & JavaBeans E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI Common Gateway Interface (CGI) is a method for generating dynamic contents of web pages. CGI programs/scripts are programs(applications) which resides and run at the server site, they: get inputs from web browser (via forms) and produces output/response (HTML code) at the server site. Then, the HTML output will be sent automatically back to the web browser, run there and display the results to users. E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI So, what it takes to build and make a CGI program works ? You will need more than just one program. HTML code to display the FORM to the users (to input INFO) CGI program which will produce another HTML code (to display results) E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI Although, it is only TWO programs but since the CGI program must produce another HTML code/output, you will need to define that HTML output (which is a program) first. So, at the end it is actually THREE programs: HTML code to display the FORM to the users (to input INFO) HTML output (to display RESULTS) CGI program which processes the INFO from the FORM (via EV) and produce the HTML output above. EV are environment variables. They are GLOBAL variables which can be shared by all programs. In CGI mechanism, EVs are shared between the Web Server program and the CGI program so that the Web Server program can pass the INFO (it received from the FORM) to the CGI program. E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI EXAMPLE 1: let’s make a simple CGI program in Python which gets first name (exp: “John”) and last name ( “Smith”) from a FORM and reply with “Hello John Smith” in the browser window. E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI Mechanism E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI  CREATE a FORM and its CGI program for displaying back INFO entered in the FORM (EXAMPLE 1)   SET-UP the a working folder for the FORM and CGI programs: Login to your CS account using Putty Go inside the WEB folder (cd WWW) Go inside your course folder (cd eb) Go inside your working folder (cd w) Create a folder called cgi(mkdir cgi-example1) Go inside that folder (cd cgi-example1) E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI Use a text editor program (jpico, emacs, vi, joe, …) to CREATE FILES inside cgi: a file named “p1.htm” which contains a HTML code to display the FORM to the users (to input INFO), with the contents showed below. a file named “p1x.htm” which contains HTML output (to display RESULTS), with the contents showed below. This file is only temporary use and can be deleted later. a file named “p1py.cgi” which contains a CGI program which processes the INFO from the FORM (via EV) and produce the HTML output above, with the contents showed below. E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI/Python E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI After “p1py.cgi” is built based on the HTML code in “p1x.htm” you can delete the “p1x.htm” file. So, you will need just two files in the db3-1 folder: file “p1.htm” which contains a HTML code to display the FORM to the users (to input INFO) file “p1py.cgi” which contains a CGI program which processes the INFO from the FORM (via EV) and produce the HTML output above. Set the permission for both files as 755 (chmod 755 *). To TEST if they work correctly: open a web browser and type the following address: cs.newpaltz.edu/~UserName/eb/w/cgi-example1/p1.htm E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) CGI/Perl Example See an example of CGI using Perl for the server program: http://cs.newpaltz.edu/~phamh/basics/CGIapplet/CGI-AppletParameters.htm E-business (constructed by Dr. Hanh Pham)

CGI/PERL for Shopping Cart Example, Demo, and Download: http://html-cart.com/ MUST set it up and run at your account at: http://cs.newpaltz.edu/~UserName/eb/w/cgi-cart/ E-business (constructed by Dr. Hanh Pham)

E-business (constructed by Dr. Hanh Pham) References Most of materials in this slide come from: searchcio.techtarget.com tutorialspoint.com http://jan.newmarch.name/ecommerce/session.html http://www.w3schools.com/ http://www.w3.org/ Wikipedia "Developing Distributed and E-commerce Applications", Darrel Ince, 2nd Edition, Pearson Addison Wesley “Web Programming and Internet Technologies: An E-commerce Approach”, Porter Scobey, Pawan Lingras, Jones & Bartlett Publishers, 2013 “Electronic Commerce”, 11th Edition, Cengage Learning, Gary Schneider, 2015 Internet & World Wide Web How to Program, 5/e, Paul J. Deitel, Harvey M. Deitel, Abbey Deitel E-business (constructed by Dr. Hanh Pham)