next up previous
Next: Writing Form Handlers with Up: Document: pillow_www6 Previous: LP/CLP Scripts for CGI

Form Handling in HTTP

  figure85
Figure 2: The Forms interface

Since CGI executables only produce output, and this output is not a function of the input, CGI executables by themselves are only of limited interest. However, they become most useful when combined with HTML forms. HTML forms are HTML documents (or parts of HTML documents) which include special fields such as text areas, menus, radio buttons, etc. The steps involved in the handling of the input contained in a form are illustrated in Figure 2. When a document containing a form is accessed via a form-capable browser (Mosaic, Netscape, Lynx, etc.), the browser displays the input fields, buttons, menus, etc. indicated in the document, and locally allows the user to perform input by modifying such fields. However, this input is not ultimately handled by the browser. Instead, it will be sent to a ``handler'' program, which can be anywhere on the net, and whose address must be given in the form itself (1). Forms generally have a ``submit'' button such that, when pressed, the input provided through the menus, text areas, etc. is sent by the browser to the HTTP server corresponding to the handler (2). Two methods for sending this input exist: ``GET'' and ``POST''. In the meantime, the sending browser waits for a response from that program, which should come in the form of a new HTML document. The handler program is invoked in much the same way as a cgi-bin application (3), except that the information from the form is supplied to the handler (in different ways depending on the system, the method of invocation and the content type) (4). This information is encoded in a predefined format, which relates each piece of information to the corresponding field in the form, by means of a keyword associated with each field. The handler then identifies the information corresponding to each field in the original form, processes it, and then responds by writing an HTML document to its standard output (5), which is forwarded by the server to the waiting browser when the handler terminates (6). An important point to be noted is that, as with simple cgi-bin applications, the handler is started and should terminate for each transaction. The reader is referred, for example, to http://kuhttp.cc.ukans.edu/info/forms/forms-intro.html for a more complete introduction to CGI scripts and HTML forms.


next up previous
Next: Writing Form Handlers with Up: Document: pillow_www6 Previous: LP/CLP Scripts for CGI

<herme@fi.upm.es>-< webmaster@clip.dia.fi.upm.es>
Last updated on Mon Mar 31 18:18:15 MET DST 1997