4. ACCESSING VISITOR INFORMATION AND ENVIRONMENT VARIABLES
EiffelWeb provides a set of classes to access information provided by the visitor, as well as the values of various environment variables.
When a visitor enters information into a form, the Web server gets it in a raw, hardly usable form. This is where EiffelWeb steps in: it parses the information, and makes it available in a form that is convenient for direct processing by your classes according to your needs.
A given field may have zero, one or move values, depending both on the field's type and on what the visitor entered in it. In usual CGI processing, there is no easy way to find out beforehand. EiffelWeb, however, enables you to obtain the information through a number of queries from class CGI_INTERFACE, which you can all apply to a field:
In the case of checkboxes and similar kinds of fields, your system will not see any field, not even an empty one, if the user did not check the box. To find out whether a field is available, use the query field_defined.
If, as is often the case, you know the name of a field, you can just pass that name as a string argument to any of the preceding queries. You can also, as in the example of section 2, loop over all the fields of the form, using the array
and passing the value of fields.item (i), for various i, to the above queries.
All the features listed in this section belong to class CGI_INTERFACE, whose complete specification appears in Appendix A.
A Web server can set a number of environment variables, which will not change during the processing of a form and so can be represented as once functions, all returning strings.
These strings are available from features of class CGI_ENVIRONMENT, whose complete specification appears in Appendix B. CGI_ENVIRONMENT also includes a procedure set_environment_variable to set environment variables to specific values, useful only for debugging.