Internet Express

By: Charles Calvert

Abstract: Internet Express

Web Development Key Concepts

This section of the paper provides an overview of key terms and concepts relevant to the Internet Express architecture. In particular, you will learn about Web Servers, CGI applications, and ISAPI and NSAPI DLLs. These subjects are covered in a fairly general, high level view, so if you have a basic understanding of them already, you can skip to the next section.

One quick point before I get started. To help make this paper more readable, I will refer to ISAPI/NSAPI technology as ISAPI technology. Unless the context of my sentence obviously dictates otherwise, you can assume that when I say ISAPI, I mean ISAPI/NSAPI. I'm shortening the term simply to make my text more readable.

Now its time to get down to cases. To get started, I'm going to give you a brief definition of a web server.

A web server is a program that runs on a network server machine. Web servers serve information up to browsers located on client machines. Netscape's Server, the open source Apache Server (http://www.apache.org) and Microsoft's Internet Information Server (IIS) are three of the most popular servers. The Microsoft Personal Web Server (PWS), a free download that runs on Windows 95, 98 and NT Workstation, is an alternative that is great for small networks and for testing. There are many other servers available, but the three I've mentioned are the ones I've seen most often.

When someone browses the web, they talk across the network to these IIS, Apache, Netscape or PWS servers. Typically, the servers then pass HTML files back to the browsers, and the user peruses the HTML. This is a great system, but appears to leave little room for the special capabilities of a Delphi or C++ programmer. The question then, is how can we, as experienced Delphi programmers, take advantage of the web?

The answer, at least in this case, is fairly straightforward. To exercise your programming skills over the web, create a CGI executable or ISAPI/NSAPI DLL. A web server can load these binary files. The web server then calls the methods in your DLL or executable, and in response your program can generate HTML that the web server will send back to the user's browser.

How then, can you call the individual methods in a CGI or ISAPI web server application? As it turns out, the answer is fairly straightforward. A CGI executable accepts parameters passed on the command line from the web server. It calls the various methods or routines in your server based on the parameters. An ISAPI/NSAPI DLL has a single entry point through which the equivalent of these same parameters can be passed.

So which is better? Should you create ISAPI DLLs or CGI executables?

CGI applications provide a simple clean solution and I find them easy to debug. ISAPI DLLs have a speed advantage, in that they can be loaded once, and stay in memory. CGI applications, on the other hand, need to be loaded over and over again, each time a new request comes in. Furthermore, a DLL can be loaded into the same address space as the server, which means that it can have a faster response time.

ISAPI DLLs can be difficult to debug since they tend to stay in memory once loaded. It can be trying to find ways to update your code without rebooting the system or bringing down your web server in order to get the DLL out of memory. Furthermore, a corrupted ISAPI DLL loaded into the address space of your server can bring down the whole server.

As a result, I tend to use CGI while debugging, and then consider using ISAPI for a release build. I should add, however, that it is possible, though not easy, to step through an ISAPI DLL in the debugger, while trying to do the same with a CGI application is much more difficult. One important aside I should make at this point is to recommend that you go to http://www.drbob42.com for help debugging ISAPI applications with the IntraBob utility.

ISAPI is a Microsoft standard, while NSAPI is a Netscape standard. Delphi allows you to write one set of code that works equally well with either ISAPI or NSAPI.

NOTE: In the future, NSAPI will disappear, and Netscape will adopt the ISAPI standard.

To switch between CGI and ISAPI/NSAPI, you need to make minor changes to your DPR file and then recompile, but the core of your application remains unchanged. It is therefore trivial to test and debug with CGI, and later switch to ISAPI/NSAPI.

CGI, ISAPI and NSAPI binary files are called web server applications. The program that loads web server applications is called a web server. This can be a bit confusing. As a result, I try to avoid the phrase "web server application", and use CGI or ISAPI/NSAPI instead. However, there are times when I will talk about web servers and web server applications, and so you should keep your eyes out for these terms.


Server Response from: ETNASC03