Tuesday, April 20, 2010

Topic 4: Web application servers

Common Gateway Interface CGI

CGI is a standard for the construction of completely dynamic HTML documents by use of an external script (small program) installed on the same machine as the Web server. Common CGI scripts require a local interpreter or compiler. PERL and Python are popularly used to process HTML forms, and can verify user inputs as well as control the return of messages and perform further processing of the forms data. On a secure Web site, CGI can still be used for some e-commerce transactions, such as ordering some perfume for your mother's birthday. The forms data is concatenated into a string of delimited name/value pairs as the following example reveals:

name=Evan+Burke&card=Visa&number=8443261344895544&order=French+perfume

Note how each variable (name, card, number and order) is delimited by an &, and the each value by a + sign.

For notes on How to setup CGI on athene (PythonCGI), go to:

http://ispg.csu.edu.au/subjects/itc594/resources/apachecgi

Common Gateway Interface Demonstrations

1. Flat-file system

A Python CGI script that runs the flat-file system at http://athene.csu.edu.au/~keustace/friends.html

Enter some dummy test data and see the flat file grow.

2. Environment variables: ZOPE and Apache web servers

The environment variable display exercise begins at ZOPE using a local Python script and end with a look at Cookies and the same environment variables display at the Apache Web server on athene. Go to : http://ispg.csu.edu.au/subjects/itc594/resources/zopecgi/envform to begin.


CGI alternatives

JavaScript, PHP, Active Server Pages (ASP), Java Server Pages (JSP) and a variety of other proprietary sources such as Cold Fusion, all provide an alternative to CGI interactivity and security. [See Figure 2-4 on Web server-enabling technologies in Conallen, p. 23]

JavaScript has been popular for including event-driven, user interface features (display a pull-down menu) and interactive multimedia (display a message or image when a mouse arrow passes over a screen area), as well as to validate data and user types into a form.

MouseOver event sample:

HREF=http://www.csu.edu.au/ onMouseOver=window.status=’Select this to go home’;return true”>Go Home

Many JavaScript samples are available from http://javascript.internet.com

Take a video lesson under 10 minutes

There are lots of video lessons on learning to use Javascript.

Douglas Crockford is my favourite: See http://video.yahoo.com/watch/111593

Code generation: Constructing a program or script

Constructing a program can be done in various ways:

· Constructing a sequence of machine language instructions to simulate the parsed statements.

· An Interpreter can execute a source program in a one-step process, with no permanent copy of the program being produced or saved. The use of an interpreter is handy when testing a program under development, as found in the Python IDE.

· Programming languages such as Pascal and C use an option to compile the final program file as one that can 'stand and run alone' as an independent application. A compiler creates a version in the native machine language of the computer.

· The Java Virtual Machine arises from a process that combines the use of a Compiler and an Interpreter. The original Java source code is translated by a Java compiler into Java bytecodes, which are similar to the machine language form. The Java interpreter on ANY machine can read the bytecodes OR another compiler can translate the bytecode form into the machine language of the host machine. Such is the distinct advantage of Java as it is:

- architecturally neutral;

- portable to all systems.

Java virtual machine

The Java language is very secure and platform-independent when compared to alternative languages. Java's secret is the tightly integrated language model. The steps below show how the Java Virtual Machine implements a Java Program:

Coding – Human-readable Java code is produced by the programmer.

1. Building – A Java Development Tool builds the Java program into bytecode, which is saved as a '.class' file.

1. Loading – Via the web or command line, the class file is sent to the Java Virtual Machine (VM) with an attached digital signature. The Java VM is simply an interpreter.

2. Bytecode verification – The Java VM verifies the digital signature.

3. Isolation When downloaded remotely, the Java VM isolates the Java program in a restricted part of memory. The Java program is not allowed to access local Hard drives and System resources.

4. Internal integrity – Verification checks are made to insure that the loaded Java program is well formed. Data types are verified along with other syntax structure.

5. Execution – Program execution begins.

Web application frameworks: From RSS and RDF to Ruby on Rails

Any development framework, from Java technologies (Java servets, JSP and JavaBeans) to Microsoft .NET and ZOPE, has provided a set of standard software components to reduce the amount of work to be done by the developer. Just as ASP.NET was one development framework for Web-based applications, others have emerged in the open source community to give us more choices – perhaps too much choice and too many to cover in his subject.

While Really Simple Syndication (RSS) introduced the notion of syndicated and subscription services to blogs, wikis and podcasts, other changes have emerged in the way we do business on the Web since 2005, though new rapid development tools.

The rise of Web 2.0 and 'Asynchronous JavaScript & XML' or AJAX has altered and extended development with an enhanced collaborative approach to building dynamic Web interfaces. Begin your understanding of Web 2.0 with Tim O'Reilly's article at http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html

What is AJAX? Visit http://developer.mozilla.org/en/docs/AJAX as your starting point for this completely different way of developing Web applications. When I started developing Web pages in 1994 we never called it Web 1.0 so what has happened to transform the Web into its second generation? Maybe you can sense or predict the arrival of Web 3.0?

Many well known online communities are using AJAX and other new programming paradigms for the Web and has also influenced Microsoft's .NET framework. See http://www.asp.net/ajax/ Prior to AJAX, a typical Web interaction had the client browser send messages to the server via a link, a URL or submitted form data and then wait for a response from the server, which may take time for server processing and for the client browser to receive and render a result on the screen. In AJAX the communication with the server is asynchronous so the browser does not wait long for the server response as small parts are displayed, resulting overall in a faster interaction 'look and feel' between the browser and the server.

Rapid database application development using 'frameworks' like Ruby on Rails, AJAX on Rails, TurboGears or Google Gears present a new architecture as part of the Web 2.0 developments. Three cases to look at here are:

· TurboGears at http://turbogears.org/ Do you agree with its rapid development approach?

· GoogleGears at http://gears.google.com See how the notion of 'an offline database' works. Examine the tools and reflect on the new knowledge that may be required in using Google Gears.

· Ruby on Rails at http://www.rubyonrails.org/ You can even download a pre-packaged solution that includes everything in one bundle: Web server, database, Ruby on Rails for both Windows (Instant Rails) and for MacOS X (Locomotive). [If you have time to go further then also test AJAX on Rails].

0 comments:

Post a Comment