Delphi Web Servers

A Web Server receives requests to provide information. Normally, the returned data is in the form of an html page. Sometimes the request simply points to an existing (static) html page which is returned without modification. Other times, the request is for data that needs to be collected and formatted based on other data (search parameters) supplied by the user. In this case, the reference points to a program and the displayed pages are referred to as "dynamic" because they are created on the fly.

Generally, there are several different ways to do this

In general, a compiled program runs about 10 times faster than an interpreted program. In addition, loading a program from the disk adds a significant amount of time. Thus, compiled programs which are loaded only once (ie, Web Server dll's), "should" provide the best performance.

Web Server dll's

A Delphi Web Server is a dll which is called by a web server such as the Microsoft Personal Web Server (PWS). The primary purpose for this is so that a web page can query a database.

Even though, the supplied help is pretty good, there are a few holes which are covered here.

Each time you compile the server, you must restart PWS
Since the dll remains loaded, you must manually stop PWS in order to try a new version.

If an Action has both a Producer and an OnAction method which contains something like the OnAction method will take presidence over the Producer

Pretend directory structure
Each ActionItem has a PathInfo property. as long as the Producer property is blank the PathInfo property can be blank. However, once the Producer property has a value, use a single forward slash (/) if you don't want an explicit pretend directory.

Stop displaying the login dialog box
Set TDatabase.LoginPrompt to false to keep the dialog box from being displayed. If a user and password are required, they can be placed in TDatabase.Params as However, these are stored in clear text (ie, security problem).

Set TDatabase.Connected true to provide a connection at design time

Pretend Directories

Using standard ASP or CGI methods (where files are close to 1 KB), families of related functions are normally implemented as separate files.

However, because the Delphi Web Server dll's have a pretty high overhead each (about 330 KB without database access, 600 KB with), it makes sense to package a family of related functions in a single dll. Using the following syntax

Delphi automatically calls the ActionItem who's PathInfo property matches the PretendDirectory. If the PretendDirectory is omitted, then the PathInfo property of the associated ActionItem should be empty; however, if the ActionItem's Producer property has a value, then the PathInfo should be a single forward slash (/). (In that case, a null value is not allowed.)


I have had significant problems getting TDataSetTableProducer to work. (It still doesn't!)

If you right click the DataSetTableProducer and select Response Editor..., the dialog box will allow you to add fields and display the expected output. In order to display the table data, set the associated TDatabase.Connected and TTable.Active to true.

There is no simple way to change the column headings - you have to write code to change them.

However, after 5 hours of trying, I still can not get any data to show up in the web page. The headers, footers, and table show up, just no data.

It also appears that setting TTable.Active to true causes PWS to hang - it is no longer possible to stop and re-start the server so that I can copy/test a new dll. All I get are sharing violations and a hung server. Setting TTable.Active to false (and re-booting) fixed that problem.

Referencing Table Data


Database Access

Delphi / Databases


Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / Databases / Delphi / WebServers / WebServers.htm