LING 408/508: Programming for Linguists Lecture 18 November 2 nd.

Slides:



Advertisements
Similar presentations
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Advertisements

Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
A simple PHP application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the application returns.
Linux+ Guide to Linux Certification, Second Edition
PZ15A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ15A - The Internet Programming Language Design and.
And so on CGI programming Web Services Java Programs for the Web.
Simple PHP application. A simple application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the.
LING 408/508: Programming for Linguists Lecture 16 October 16 th.
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.
Java Server Programming Jeff Schmitt Towson University October 15, 1998.
CGI Programming Languages Web Based Software Development July 21, 2005 Song, JaeHa.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
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.
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
LING 408/508: Programming for Linguists Lecture 17 October 21 st.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
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,
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
USING PERL FOR CGI PROGRAMMING
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
CS4273: Distributed System Technologies and Programming I Lecture 7: Java Networking.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
LING 408/508: Programming for Linguists Lecture 4 September 2 nd.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
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
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
LING 408/508: Programming for Linguists Lecture 17 October 28 th.
LING 408/508: Programming for Linguists Lecture 8 September 23 rd.
CSCI 330 UNIX and Network Programming Unit IX: Shell Scripts.
 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.
LING 408/508: Programming for Linguists Lecture 5 September 9 th.
1 HTML forms (cont.)
World Wide Web Components Browsers and Servers CGI Processing Model (Common Gateway Interface) © Norman White, 2001.
(see online resources, e.g. SY306 Web and Databases for Cyber Operations Slide Set #9: CGI with Python.
LING 408/508: Programming for Linguists Online Lecture 6 September 14 th.
Lab 8 Overview Apache Web Server. SCRIPTS Linux Tricks.
CS 330 Class 8 Homework A pattern that contains a word with an optional period A pattern that contains Fred with a space (not Freddy) See regexp.txt guest4.htm.
LING 408/508: Programming for Linguists Online Lecture 7 September 16 th.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
Linux Administration Working with the BASH Shell.
 Prepared by: Eng. Maryam Adel Abdel-Hady
1 The Internet Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
© 2004 D. J. Foreman T&F-1 CS205 Tables & Forms. T&F-2 ©2007 D. J. Foreman Tables.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
Prepared by: Eng. Maryam Adel Abdel-Hady
Introduction to CGI and ajax
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
Introduction to CGI and ajax
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
World Wide Web Components
CS205 Tables & Forms © 2012 D. J. Foreman.
CS205 Tables & Forms © 2008 D. J. Foreman.
CS205 Tables & Forms © 2004 D. J. Foreman.
Presentation transcript:

LING 408/508: Programming for Linguists Lecture 18 November 2 nd

Today's Topic Sending form data to the webserver 1.GET method 2.POST method There are also other methods to communicate information depending on the kind of webserver we run: – e.g. Apache Tomcat (for Java) – e.g. Websocket interface (for bidirectional data passing) – etc.

Sending information: GET HTML form: 1. 2.First: 3.Last: Information encoded using alphanumeric characters: why? URLs are restricted to alphanumeric characters only bash accesses the URL-encoded string via the environment variable QUERY_STRING

Sending information: GET get.cgi: 1.#!/bin/bash 2.echo "Content-Type: text/plain" 3.echo 4.#echo $QUERY_STRING 5.origIFS=$IFS 6.IFS='=&' 7.set -- $QUERY_STRING 8.IFS=$origIFS 9.echo "1: 2: 3: 4: " In bash: – IFS = internal field separator (for arguments) – default: space newline tab –set -- String – -- option: positional parameters $1,$2,..etc. are set after splitting String = and &

Sending information: GET get.cgi: #!/bin/bash echo "Content-Type: text/plain" echo #echo $QUERY_STRING origIFS=$IFS IFS='=&' set -- $QUERY_STRING IFS=$origIFS echo "1: 2: 3: 4: "

Sending information: GET OS X /Library/WebServer/CGI- Executables/ $ls -l get.cgi -rwxr-xr-x 1 root wheel 161 Oct get.cgi sudo chmod 755 get.cgi Ubuntu /usr/lib/cgi-bin/

Sending information: POST HTML form: 1. 2.First: 3.Last: bash accesses the URL-encoded string on standard input via read

Sending information: POST bash accesses the URL-encoded string on standard input via read read.cgi: 1.#!/bin/bash 2.echo "Content-Type: text/plain" 3.echo 4.read input 5.origIFS=$IFS 6.IFS='=&' 7.set -- $input 8.IFS=$origIFS 9.echo " "

Sending information: POST

Limitations of positional parameters GET values: origIFS=$IFS IFS='=&' set -- $QUERY_STRING IFS=$origIFS echo "1: 2: 3: 4: "

Another Example Suppose we want to maintain a list of names on the webserver stored in a file names.txt – MySQL would be a more sophisticated approach (hint!) Design a webpage to add names to this file and print out the table of names

Homework 9 Use cgi-bin to implement a BMI bash shell script on the webserver – i.e. you should modify your BMI program to accept data from a html form and compute the value on the server side Use both GET and POST methods to communicate the weight, height and units. Submit your.html and.cgi files Submit screenshots to show it working in both cases