SIMPOL Documentation

Chapter 11. SIMPOL Web Server Applications

Introduction

One of the powerful features in the new SIMPOL language is the built-in support for producing web server applications. The key to this is the cgicall type and the various loader programs for supporting this type. SIMPOL supports several standard ways of working with this type, which provides access to the Common Gateway Interface (CGI). This includes standard CGI, ISAPI (Internet Information Server API), and Fast-CGI. All of these technologies work in similar ways and ISAPI and Fast-CGI are based on the older CGI technology.

A significant difference between the ISAPI approach and traditional CGI is that the ISAPI server extension is normally loaded once and then left loaded, whereas the standard CGI program is loaded and then unloaded each time it is called. The advantage, especially in the case of an interpreted or byte-code compiled program is that the interpreting environment is left loaded and only the program must be loaded and run each time. This is similar to Microsoft's ASP (Active Server Page) and Sun's JSP (Java Server Page) technology in that the interpreters for these technologies are built in or else dynamically loaded by the web server enabling them to provide improved performance. One difference in this is that SIMPOL programs are not combinations of code and HTML markup, but are instead compiled programs. The difference in performance can be considerable. The ease of design of ASP and JSP pages is also supported within the SIMPOL IDE. Using the server page support SIMPOL source code can be mixed with HTML on the same page in exactly the same style as in ASP pages. When the project is compiled, the server page is also compiled, providing the best of both approaches — mixed-mode design plus the speed of compiled code.

If performance is really what you are looking for though, then the real answer is Fast-CGI. Using the Fast-CGI support in SIMPOL it is possible to not only load the execution environment and leave it loaded, it is also possible to load the actual program and allow it to perform its initialization once and then thereafter only respond to calls. This approach is the fastest that is realistically possible (short of adding a special program in a compiled language like C directly to the web server code). A SIMPOL Fast-CGI program has an initialization function, an execution function, and a termination function. The initialization function is only called the first time the program is loaded. The execution function is called each time a call is made to the program by the web server and the termination function is called only when the program is being unloaded. Fast-CGI is currently supported by a number of web servers on various platforms, most notably though by the Apache web server.

All of these technologies are very unified in the way that they are implemented in SIMPOL. In each case a parameter of type cgicall is passed to the starting point in each program. In each case the program can then act in a similar fashion, retrieving server variables using the getvariable() method or key values from a posted form using the keyvalue() method. In fact, with careful design it is possible to write a program that will work in all environments without change. Such examples can be found in the examples included with the product. One item of good design that is used consistently throughout the examples is that of storing parameters that might change in a configuration file and retrieving them at runtime. This means that the program does not need to be recompiled or modified to run in different locations or even on different platforms.