O'Reilly logo

Beautiful Code by Andy Oram, Greg Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Maintaining a Dialog with the User over the Web

The Gene Sorter is a CGI script. When the user points her web browser to the Gene Sorter's URL (http://genome.ucsc.edu/cgi-bin/hgNear), the web server runs the script and sends the output over the network. The script's output is an HTML form. When the user hits a button on the form, the web browser sends a URL to the web server that includes the values in the drop-down menus and other controls encoded as a series of variable=value pairs. The web server runs the script once more, passing the variable=value pairs as input. The script then generates a new HTML form in response.

CGI scripts can be written in any language. The Gene Sorter script is actually a moderately large program written in C.

A CGI script has both advantages and disadvantages compared to other programs that interact with users on the desktop. CGI scripts are quite portable and do not need different versions to support users on Windows, Macintosh, and Linux desktops. On the other hand, their interactivity is only modest. Unless one resorts to JavaScript (which introduces serious portability issues of its own), the display will be updated only when the user presses a button and waits a second or two for a new web page. However, for most genomic purposes, CGI provides an acceptably interactive and very standard user interface.

The lifetime of a CGI script is very limited. It starts in response to the user clicking on something and finishes when it generates a web page. As ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required