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
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.
- CGI files
are executed each time they are called.
Perl is the most popular language for these,
but they have to be interpreted each time they are called.
- Web Server dll's are loaded into memory once.
Subsequent calls start a new thread and
do not load a new instance.
(Active Server Page) is a Microsoft proprietary
method to provide active content using a fully functional
These are generally written in Visual Basic (actually VB Script),
or Java Script,
and are interpreted.
- IDC/HTX is a Microsoft proprietary method to provide
simple database access.
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
Response.Content := 'Some String';
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
Using standard ASP or CGI methods
(where files are close to 1 KB),
families of related functions are normally implemented as
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
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
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
Response.Content := Response.Content +
Delphi / Databases
Author: Robert Clemenzi -