Docsity

Extending Web Functionality - Lecture Slides | CS A331, Study notes of Programming Languages

Toggle sidebar
bg1
1
Extending Web Functionality
• Programming tools are needed to extend
web functionality beyond pure publishing.
• CGI
– Common Gateway Interface
– Server Side Includes
• Java / Java Applet / Java Servlet / JSP
• ActiveX
• JavaScript / VBScript
CGI
• Programs (compiled or interpreted) running
on the server
• Provide interactivity with the user for
forms, images (e.g. counters)
– User inputs data on a form
– Upon submit, the data is transmitted to the CGI
– CGI program operates on the data and typically
transmits something back (HTML, image, etc.)
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Extending Web Functionality - Lecture Slides | CS A331 and more Study notes Programming Languages in PDF only on Docsity!

Extending Web Functionality

• Programming tools are needed to extend

web functionality beyond pure publishing.

• CGI

  • Common Gateway Interface
  • Server Side Includes

• Java / Java Applet / Java Servlet / JSP

• ActiveX

• JavaScript / VBScript

CGI

• Programs (compiled or interpreted) running

on the server

• Provide interactivity with the user for

forms, images (e.g. counters)

  • User inputs data on a form
  • Upon submit, the data is transmitted to the CGI
  • CGI program operates on the data and typically

transmits something back (HTML, image, etc.)

Global Environment Variables

CGI

Browser HTTP Server

Html page

Form Data

Results - CGI Program HTML or Image or Sound or ...

Web Server

CGI Problems

• Load on the server

• Security issues

  • if a leak, user could get access to the web server

• Inefficiencies

  • Program is loaded for each request
  • Possible to have in-memory modules for better

efficiency

CGI Programming

• Often in Perl, ASP (Active Server Pages)

• Can use C, C++, .NET Languages

• We will use PHP

• Either an interpreted or compiled language

• NOT a language implemented in your

browser, like Javascript or VBScript

Server Side Includes

• Hidden directives in your HTML to execute

a program and insert its output into the web

page

•

• Format varies on different browsers

HTML Here blah blah...

More html here…

Java Applet

Applets downloaded to local PC, execute there

Java Applet Usage

• The applet is embedded like a HTML tag:

…

Example JavaScript Code

Java vs. JavaScript?

• Both run on the client

• Interpreted Java/VBScript runs slower

• Somewhat limited programming language

constructs available in JavaScript

• Easier to do simple tasks, formatting tasks,

interface with Fields in Forms in JavaScript

Java Servlet

Java Server Pages (JSP)

ActiveX

Browser HTTP Server

Html page + ActiveX Program

ActiveX Program - A regular Windows Program!

Web Server

Possible Communications with anywhere. Lax security restrictions.

Basic CGI Example

• Receiving, Printing GET/POST Data

HTML:

Here is a form:

Form

CGI Code, in PHP

CGI Test"); print(""); print("Submission Received"); print(""); if ($_SERVER['REQUEST_METHOD'] == 'GET') { print(" GET Query:

"); print_r($_GET); print("

foo = ". $_GET['foo']. "bah = ". $_GET['bah']. "

"); } else { print(" POST Query:

"); print_r($_POST); print("

foo = ". $_POST['foo']. "bah = ". $_POST['bah']. "

"); }

?>