Author:admin

Date:2008-09-17T13:53:28.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@3 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
jfiat
2008-09-17 13:53:28 +00:00
parent 4fee9356ea
commit 2ee31ab9c7
763 changed files with 36576 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
[[Property:title|EiffelWeb Content Introduction]]
[[Property:weight|0]]
==CGI Applications==
The way a CGI application communicates with the Web browser is simple: when the user presses a button on an HTML form, with an associated action (such as ''Submit''), the browser starts the application whose path is indicated inside the HTML form declaration. It sends data corresponding to the HTTP request and to the input form information in the usual file descriptor ''In'', stores within environment variables the transaction environment of the request, and waits for the application message, expected in its ''Out'' canal. The ''In'' and '' Out ''canals are accessible via the class CGI_IN_AND_OUT. <br/>
<br/>
HTML forms are an easy way to collect user entries in a web page, which are sent by the browser to the CGI application. A simple example of a form is:
<code>
<form action="/cgi-bin/convert.exe" method="post">
<input type="text" name="Celsius">
<input type="submit">
</form >
</code>
When the user presses the submit button, the browser will launch the application located at ''/cgi-bin/convert.exe'' on the server, will use the HTTP Post protocol, and will store among others the environment variable ''Celsius'' with the value entered by the user.
==Advantages of using EiffelWeb==
With EiffelWeb, you can:
* Design object-oriented systems
* Access and use the Eiffel libraries
* Increase maintainability because your code is reusable and readable
* Deal with complexity because you use a language particularly efficient in the Business Modeling.
* Use one/a few big Eiffel Web applications, which allow for an easier maintenance and provide better code readability and reusability than having a huge number of scripts.
* Use the ''Design by Contract'' methodology, thanks to the debugging facilities provided by EiffelWeb.

View File

@@ -0,0 +1,12 @@
[[Property:title|EiffelWeb Content]]
[[Property:link_title|EiffelWeb Tutorial]]
[[Property:weight|0]]
The Common Gateway Interface (CGI) emerged as the first way to present dynamically generated information on the World Wide Web. It allows the computer to process forms filled by the user and return appropriate information. <br/>
EiffelWeb was developed by Interactive Software Engineering to provide Eiffel developers access to the CGI technology. The library makes it possible to write Eiffel systems that interact directly with the WEB.
{{seealso| '''See Also''' <br/>
[[EiffelWeb Content Introduction|Introduction to EiffelWeb]] <br/>
[[Processing Requests|Processing forms with EiffelWeb]] }}

View File

@@ -0,0 +1,53 @@
[[Property:title|Processing Requests]]
[[Property:weight|1]]
EiffelWeb provides a complete set of features and interface which helps building a wide range of possible requests.
==Basic CGI Handling==
===Accessing Environment Variables===
Much of the information needed by CGI applications is made available via environment variables. Programs using EiffelWeb can access this information through the class CGI_ENVIRONMENT. <br/>
These variables are usually used for the following purposes:
* Getting information about the server itself
* Checking the client browser
* Restricting Access for specified Domains
* Ensuring User Authentication and Identifications
* Dealing with Cookies
===Accessing Input Values===
The browser sends in the ''In'' a stream containing the data relative to the user entry and selection at the applications starts. EiffelWeb stores each data element and its associated name within a Hash-Table, the feature form_data of class CGI_INTERFACE. You can access their values from your code with the interface defined in class CGI_FORMS, which allows you to retrieve text entries, to know whether a button was pressed or not, etc.
===Sending answers to the browser===
The response has to contain an HTTP header in order to be understood by the browser. Depending on the nature of the reply, an HTML page, a simple re-direction, an error notification, you will select different features and options. Your application must send at least a response header, indicating the status of the request if known. You may want to attach to it the text you wish to send back to the user. This text is usually written in HTML, so that it will display nicely on the user's browser; you can use for this purpose the class HTML_PAGE. You may then send the header followed by your text using the features send_to_browser of classes CGI_RESPONSE_HEADER and HTML_PAGE.
{{note| '''Note''': You may not write into a file before you have sent the answer to the browser. }}
===Dealing with Cookies===
You can access the cookies corresponding to a specific URL/domain thanks to the feature cookies, of class CGI_ENVIRONMENT. It is a hash-table, in which all the data with associated names as keys are stored.
To store a cookie on a machine, you can use the feature set_cookies, of class CGI_RESPONSE_HEADER.
==Advanced Topics==
===EiffelWeb and Security===
The information the server sends back may be confidential. Follow these steps to protect the page content:
# Create an HTML page, for example by using class HTML_PAGE.
# Store this page somewhere, with a random name.
# Create an instance of class CGI_RESPONSE_HEADER and choose the secure redirect option. Then call send_to_browser.
===Complex Headers===
The Eiffel-Web application has the possibility to send a selection of different HTTP headers. They can be found in class CGI_RESPONSE_HEADER. In particular, it is advised to generate a status for each request, the value of the most common ones may be found in class CGI_ [[ref:/libraries/web/reference/cgi_common_status_types_chart|COMMON_STATUS_TYPE]] .
===Debugging facilities===
Design by Contract is one of the greatest strengths of the Eiffel language. When you usually run your application from EiffelStudio, you are notified when an assertion is violated and the tool offers different options in order to be able to find out its sources (feature and class tools, object inspectors, etc). However this cannot be applied to an EiffelWeb application, since it has to be run on the server. <br/>
Therefore, EiffelWeb provides its own facilities for debugging. To test your classes at run-time, all you need to do is to set the Boolean feature is_debug_mode to <code> True </code> in your root class (which should inherit from CGI_INTERFACE). When your application crashes (because of an assertion ora bug), the exception trace will be displayed on the screen.