CGI programming Using Apache. Concepts Browser prepares parameter list List is attached to name of program to run on server "submit" button sends string.

Slides:



Advertisements
Similar presentations
Client-server practices DSC340 Mike Pangburn. Agenda Overview of client-server development Editing on client (e.g., Notepad) or directly on server (e.g.,
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
CPSC 203 Introduction to Computers Tutorial 59 & 64 By Jie (Jeff) Gao.
Using KompoZer -- a web editor A collection of video tutorials
JavaScript Forms Form Validation Cookies CGI Programs.
Building Web Pages With Microsoft Office. Introduction This tutorial is for the beginning web builder. It utilizes software that you already have, Microsoft.
Exploring the Internet Creating and setting up your website Instructor: Michael Krolak Instructor: Patrick Krolak See also
Exploring the Internet Creating and setting up your website Instructor: Michael Krolak Instructor: Patrick Krolak See also
Python and Web Programming
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.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
CS 1704 Introduction to Data Structures and Software Engineering.
INTRODUCTION TO WEB DATABASE PROGRAMMING
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Web Design Using HTML Codes. WHAT DO I NEED TO BEGIN DESIGNING A HOME PAGE? 1.YOU NEED A FOLDER (also called a DIRECTORY) You should set up a folder or.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
CPSC 203 Introduction to Computers Lab 21, 22 By Jie Gao.
Links in HTML. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another web page on the same.
CGI programming Using Apache. Concepts Browser prepares parameter list List is attached to name of program to run on server "submit" button sends string.
1 HTML References: A HTML Tutorial: /HTMLPrimer.html
CSE 305 Theory of Database Tutorial on Connecting with Sybase from Java program and Developing GUI Jalal Mahmud, TA, CSE 305.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Background - hardware User interface devices to system –Mainframe Text mode only Command-line (text mode) interface “Some” menus available (NOT a GUI)
Python CGI programming
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
CPSC 203 Introduction to Computers Lab 23 By Jie Gao.
HTML Hyper Text Markup Language A simple introduction.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
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.
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.
JavaScript. During the last lecture We looked at the utility of forms on Web pages We found out about the various components that are used in a form We.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 HTML Forms
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Introduction to JavaScript CS101 Introduction to Computing.
Implementing and Using the SIRWEB Interface Setup of the CGI script and web procfile Connecting to your database using HTML Retrieving data using the CGI.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Landscaper 101. Time Code AMC AMCNET HELP!!! Where do you go for help? –Upper right corner has a ? for the online help –This presentation.
Web Authoring with Dreamweaver. Unit Objectives  Be able to define keywords: HTML, HTTP (protocol), browser, web server, client/server, tag, attribute,
1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile.
HTML Hyper Text Markup Language. The Basics u HTML documents contain “tags” which instruct the Browser software on how to present the information within.
Accessing VM – Step 1 (booting your Linux system) CMS G7 Q3270 /X3270 Win… MTN3270 (Mocha) BINGTJW.CC.BINGHAMTON.EDU CP z/VM Linux systems.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring Forms, HTML5 layout.
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.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Creating Web Pages with Links, Images, and Embedded Style Sheets
INTERNET APPLICATIONS CPIT405 Forms, Internal links, meta tags, search engine friendly websites.
INTERNET APPLICATIONS CPIT405 Install a web server and analyze packets.
HTML Hyper Text Markup Language. Agenda Basics Tools Important tags Tables & databases Forms Publishing at Stern.
Basic Web Design UVI CELL Dave Gilliss Dave Gilliss
Logging in to CMS from off-campus
CGI programming Using Apache.
Example of a table. Note that I looked at an example under CIS44.
Java Applets.
Logging in to CMS from on-campus
CGI programming Using Apache.
Logging in to CMS from on-campus
Presentation transcript:

CGI programming Using Apache

Concepts Browser prepares parameter list List is attached to name of program to run on server "submit" button sends string to server as name/value pairs Server locates program in CGI directory Server loads program Server passes string to program Program processes parameters and acts as needed Program creates strings and outputs to server One line of HTML code per output statement (cout, printf, etc) ALL stream output goes to the Server Server sends strings to browser Browser interprets the HTML code & displays the "page"

CGI output (C++ example) #include cout << "Content-Type: text/html\n\n" << endl; cout " << endl; // HTML 5 cout " << endl; …. Your HTML & text go here … cout " << endl; 1 st line identifies output media type to browser 2 nd line identifies document type version 3 rd line is actual start of the page

Content-type problems Inability of data source to identify content Wrong file extension Bad file extension Extension collisions Ambiguous container formats Ambiguous magic numbers Inability of receiver to trust sender's media type Programmers try to guess content type by examination

Using styles Output is a stream representing a single "file" HTML files do NOT have to have one tag per line Output can be individual lines or several long lines: cout text item1 "<<endl; Styles can be embedded or inline Generate style tags just like any other HTML cout.red {font:red} " << endl; cout << ".bigtext {text-size:150%} " << endl; " << endl;

Using JavaScript JS can be inserted: as functions in As inline code inside in body of doc CGI generated pages "act like" real pages

Getting to your server Connecting to the TJW machine Go to SSL>BINGHAMTON>EDU and download the MTN3270 (Mocha) program Edit the properties of mtn3270 to be sure you are going to bingTJW, not bingTZ1. Login to the TJW mainframe using MTN3270 Your 3270 userid & password are on my Grade Tracker Follow the prompts then type: #CP DISC" and your session will disconnect. Close the window. Login to TJWnnn.cc.Binghamton.edu using Putty or SSH The userid & password will ONLY be given to you in class. You can now use the editor named “nano” to edit files. To work in full GUI mode, type: vncserver It will prompt you for a NEW password. Make one up. This will be for your VNC client to connect (for a 3 rd time) to your system. I recommend the freeware program called “tightvnc”. You can now close Putty. Download & install your VNC client, then use it to login in GUI mode

Navigating a website Do I have to install Apache on my PC? No. The Apache server is only on the server (TJW) and is already installed. Here is the data flow: 1.User has your form “somewhere”. It could be a simple file on their hard drive or in the HTML folder of your webserver machine (TJW in this case). 2.User completes the form and clicks “submit” 3.The “action=” attribute of the FORM tag tells their browser to gather the input fields and send them to wherever the “action” attribute says to send them 4.The TJW Apache server sees the incoming request for your CGI program. The program MUST be in var/www/cgi-bin directory (after you compile it on TJW and move the executable-output (a.out) there from your home directory.) You SHOULD rename a.out to something more meaningful and that is the name to use in your “action=” attribute. 5.The Apache server loads the program and passes your input fields as command-line arguments, just like any program started form a command-line. Your program gets them via: void main(int argc, char*argv[]) {} 6.Your program gets the data, processes it and outputs a webpage as we discussed in class. The output is sent by the Apache server to the user’s browser which then displays the page you built with the results.

Activating your CGI program Generate an HTML form (using cout or printf): … {your JS function def's and html and go here} document.myform.submit(); // this submits the form to the browser Where I have "chkflds" you could put the name of a function to validate the fields The function would have to be inside and tags RECOMMENDATION: put the form's elements inside a table.. Input/button tags here…

Setting up your Apache server Open terminal window Type: nano /etc/httpd/conf/httpd.conf (or use your favorite editor instead of nano) Locate "ServerAdmin" and replace the address with yours Locate "ServerName" and replace the default with your TJWnnn account (tjwnnn.cc.binghamton.edu) Save the file using the same name it had In the terminal window type the following command: apachectl start Close your session

Testing your web server Create a simple web page Save it in /var/www/html with the name: index.html Open a browser on your own PC (NOT on the TJW machine) Enter the address of your tjw account e.g.; tjw241.cc.binghamton.edu (that's mine!!) You should now see your test page