Last Modified: 1/29/08
  Computer Training
Server-Side Languages


Server side languages for the web operate as CGI (Common Gateway Interface) programs. CGI is not a language itself but rather is a protocol for communicating between the server and the client web browser. This protocol can be implemented by many languages, of which the most common are Perl, C, C++, various Unix scripts, Rexx, and Python. Perl is by far the most widely used at present. These languages might be described as follows:

  • Specific language characteristics: Perl is an interpreted language which is especially good for "Here Documents", Regular expressions, associative arrays, and easy access to the operating system. "Here documents" are useful because CGI programs typically write other programs, either in the form of HTML or embedded HTML scripts, such as JavaScript. They let you enclose entire HTML/SCRIPT programs without any modifications between start and end lines of the form:
    print <<ANY_END_STRING
      blah blah blah
      . . .
    ANY_END_STRING
    
    (see this for an example of a "Here" document which prints out a program for a Gnuplot graph). The only exceptions are a few special characters, such as "\n" or "\t" often found in JavaScript which need to be doubled, e.g., "\\n" or "\\t".

    Regular expressions are difficult to get used to but once learned make it very easy to locate and/or modify text strings, and associative arrays let you locate and manipulate arrays by easily understood text indices, rather than numbers, e.g., $phone_number{"John Jones"} is much more understandable than $phone_number{273}.

    Perl 5 also has some Object Oriented capabilities.

    C and C++ are also widely used but are compiled languages and lack the regular expressions and "Here documents" that are so useful in Perl.

  • Characteristics in common: these languages live entirely on the server. They can receive information from the client, usually by way of the Submit button which transfers control and the name-value pairs in the form to the server, and they can rewrite HTML client side pages and send them to the client, but they cannot modify anything on the client, except for rewriting the page.

  • Invocation: you can invoke them through a URL, and can pass parameters to them though the URL followed by "?p1=value&p2=value&p3=value" (the GET method: see this for a very simple example of a CGI program invoked by typing a URL into a browser, and this for a more complex example). The most usual way is by pressing the submit button associated with a form which transfers control to the CGI program along with the parameters in the form. You can also invoke them through the #exec Server Side Include function in HTML scripts whose file extension reads .shtml as opposed to just .html (see this for an example, and see this for the source code)

  • Advantages: access to the same environment on the server machine that any user program has, except when specifically restricted by the Web administrators. Thus all programs, files, graphics (see this for an example of a Gnuplot CGI file), databases, environmental variables, and system calls, accessible thru any normal program are available. In addition, there is information associated with the Web interface, and a small amount of information (such as supported MIME types and the browser name/ version) about the client browser.

  • Disadvantages: these languages cannot *change* anything on the client: they can only *re-write* web pages which they transmit as a whole. Also, the speed and uniformity of response is lacking, since communication is thru modem or E-net, and the load on the server is varying (see this for an example as well as instructions for typing in a URL which implements animation. Although this method works, the animation is rather slow and jerky, and is useless over a low speed line since the images don't appear to be cached. When this is called through a SUBMIT button using client-pull animation the animation is constantly interrupted by requests to repost the data).

  • Mixing client and server side scripts: you can fairly easily combine client and server (CGI) scripts to work together. Here is an example of JavaScript program that writes HTML which lets you to specify the locations of people, but which calls a CGI Program to make those changes permanent.
Previous Home Next

Course Topics

Client-Sever Relationships

Markup Languages

Properties of Web Languages

Client-Side Languages

Server-Side Languages

 
Previous Home Next

©1999 UW Technology