This sample shows how to retrieve and display information from a basic form on a web page.
Note: This sample requires a web server supporting CGI in order to be run. Both the Internet Information Services web server from Microsoft and the GNU Apache server may be used.
To compile the example:
The workbench version of the example (i.e. the version compiled either by melting or freezing) relies on the file web_demo.melted to execute properly. However the process is launched by the web server which means that this file will not be in the path of the application. It is possible to set a registry entry that will tell the Eiffel runtime where to find this file. The sample includes the file web.reg that you can edit by replacing the line:
"MELT_PATH"="c:\\eiffel52\\examples\\web\\basic\\eifgen\\w_code"
with the path to the W_Code folder where you have compiled the example (the W_Code folder is located underneath the Eifgen folder). Once you have edited the file, simply double click it to register the changes in the registry (click Yes when prompted).
You should then copy the file web_demo.exe in the cgi_bin directory of your web server and the file sample.html in a directory on the web server.
To run the example, access the page sample.html that you copied on the web server with a web browser (typically http://localhost/sample.html). Fill in the text field with a username and click Submit. You should see a page displaying the name you jsut entered. Although not earth-shattering, this sample shows the basis for building more complex forms processing in Eiffel.
This basic sample has just one class SAMPLE which inherits from CGI_INTERFACE. SAMPLE implements execute which retrieves the name entered in the form and creates a new HTML page with it.
See the reference for the class interfaces.