Request and Response

Web applications are characterized by a request and response method. This is always initiated by the user, never by the Web server. By entering a URL in the browser the user starts an AFP application.

Please bear in mind that the user may enter any URL of his choice. For this reason you can't be sure that specific pages will be processed in a specific sequence. The user is not limited to .afp files - he can request all files in the directory. Normally, a Web server will deliver the contents of a file if it is unable to interpret the file. If you can not deactivate this behavior, you will forward all file extensions to AFP3.DLL with the exception of files like JPG, HTML, GIF, and so on. In the AFP pages you can use the event PageCallBefore to block direct access to a page.

Whenever the user requests a URL, it will be relayed via the Web server to the AFP. The AFP will then run that page in any available instance. The result will be returned to the browser only after the page has been completely processed. As far as the Web server is concerned, this process is then finished. It is now up to the user to decide whether or not he wants to send a new request. If your application requires dynamic actions in the browser these have to be performed through DHTML and scripts. AFP 3.0 can not be used for scripts that are executed on the client. The code is usually VBScript or JScript. If and how it will be executed depends on the browser.

HTTP differentiates two key access methods: GET and POST. There are still more, but those are normally not required. Through Request.ServerVariables("REQUEST_METHOD") you can ascertain the method that was used to access your Webpage. Any time a user enters an address, it is a GET access. If you defined an HTML form and entered it as POST method, the access type is POST:

<form method="POST" action="<%Session.Url()%>">

In the majority of AFP applications the user will collect data that have to be processed by the AFP application on the server. By using the different access methods you will be able to accommodate both the form and the code to be processed in one and the same file.

<%

      IF Request.ServerVariable("REQUEST_METHHOD") == "POST"

             * Process data here

      ENDIF

<%

Any Web server response can be assigned a validity period. In AFP 2.x, the page validity was unlimited by default. The result of this was that the browser would frequently fail to re-load a page with dynamic content. In AFP 3.0, by contrast, each page is marked as invalid. At every access, the browser will re-load the page. You can control this behavior through the properties of Response.Expires:

Response.Expires = Date() + 1

In normal conditions the default setting is the better choice. In HTML forms the result may be that during printing the fields displayed to the user are empty, or that upon return to the form a message appears indicating that the content of the page has expired and the page should be re-loaded. In this case, all previously made entries will be lost. This behavior is especially prevalent with Netscape browsers. To sidestep this issue, add the above code line to your page.