next up previous
Next: Predicates for Creating Form Handlers Up: Using the Package Previous: Extending the Package

Predicates for Producing HTML Executables

  

An HTML executable is a standard executable which resides in a directory which is recognized by the corresponding httpd server as containing executables. The set of such directories normally includes /cgi-bin, but most httpd servers can be configured so that other directories are also included in this class. CGI stands for ``Common Gateway Interface'', see this document for a good introduction of CGI scripts and HTML forms.

When access to a standard document is requested by a browser, the httpd server normally simply returns the contents of the file (which is normally in HTML format). However, if the requested address corresponds to a file in an executable directory then the server first runs the executable and then returns to the requesting browser the output produced by such run (which is normally in HTML format or another format which can be handled by the browser). HTML requests to executables are generally information requests and Logic Programming is a natural choice for developing applications capable of fulfilling such requests.

Developing a WWW executable in Prolog simply amounts to producing a Prolog program which, when executed, returns an HTML document. The formatting facilities presented in the previous sections can be used for providing such a document. The Prolog executable can be produced using the usual techniques in Prolog, i.e., through a saved state or by generating a stand-alone executable. At CLIP we have also developed a simple package for creating ``Prolog scripts'', i.e., files containing source code which simply run when executed, in the same way as is usually done, for example, with shell scripts in UNIX (this package will be released soon).

The Prolog HTML package also contains some simple predicates which somewhat simplify the operation of producing a cgi-bin executable:

save_cgi_bin(Name,EntryPoint)
creates an executable corresponding to the current state (using a saved state, only available in systems which support them). The name of the executable will be Name and the entry point when the executable is called will be EntryPoint. The executable will also contain an exception handler which produces suitable output (via an HTML document) if the application fails or gives run-time errors (see the next predicate). The warning icon used in these messages can be changed through the predicate icon_address/2. See the source file for details.

html_protect(Goal)
Protects the execution of the goal Goal so that if it fails or gives run-time errors suitable HTML output is produced.

The following section explains the facilities provided by the package for creating form handlers, including the parsing of input from HTML forms.


next up previous
Next: Predicates for Creating Form Handlers Up: Using the Package Previous: Extending the Package

Mon Mar 18 21:38:39 MET 1996 <clip@dia.fi.upm.es>