Next: Using Lex for CGI Up: Implementation of the Tutorial Previous: Coding the Question Forms

The Server (CGI) Side

When the submit button of a form is clicked, the Web browser client sends a message to the server much like the message sent for any other link. The difference is that in this message the client is also sending information to the server, not just requesting information. In particular, the client sends a string which encodes the information in the form.

On the server side, the information received from the client is processed by a program referred to as a CGI script. This script may be any executable program written in any language. For this experimental C tutorial, the scripts are written in C using Lex to assist.

Lex [8] is a compiler-writing tool that reads a file consisting of regular expression/action pairs. (Complete introductions to regular expressions can be found in most texts on formal languages and automata theory e.g. [2,6,8].) Lex's output is a file containing the C code necessary to recognize the regular expressions and take the specified actions upon seeing each expression. In this project, we use the GNU version called flex.

Regular expressions are a natural way to describe the form data. For a strictly determined message such as that for a multiple-choice question, the regular expression is very simple. For the short answer questions, the regular expression can be used to describe the correct answer while still allowing some flexibility in the input (e.g. white space). Using regular expressions also opens up the possibility of recognizing common general forms of mistakes without forcing us to list every mistake exactly.

Brian L. Stuart
Mon Aug 12 16:20:19 CDT 1996