Delphi WebServer Structure

This data applies to both CGI and ISAPI web servers.

Web pages are built in a sequence

Basic | WebActions | PageProducer | TableProducer | DataModules


Basic Capabilities

Basically, this is a repeat of WebServer_CGI ... but without a database connection. It creates a very simple WebServer just to verify that everything is ok.


WebActions

Every web server must have at least one WebAction - most should have several. These are the actual entry points used by Delphi.

Of your available actions, one (and only one) should have the Default property set to true. This action will be called in the event that no action is explicitly called.

One way or another, the WebAction must return an html page. This can be via its OnAction event or generated by a Producer. Delphi 5 provides the following 4 Producers on the Internet tab.

To add a WebAction, double click on the white space in the WebModule (or right click and select Action Editor..., or right click in the tree view and select Add item).

PathInfo is used to select which WebAction is called.

It is automatically assigned to the name of the associated Producer ... modify it as appropriate.


PageProducer

The PageProducer is the simplest way to test your server


TableProducer

Table producers should have headers and footers if you want them to produce a complete page. If they are called into a frame, then it is not as important ... the frame's title appears in the title bar

Netscape really wants all pages to have titles, otherwise, the backbutton just shows numbers

***** Web pages are built in a sequence the WebActionItem calls OnAction, place html in Response.Content the Producer is called PageProducer - Provides an html file or a StringList TableProducer - General html is in Header and Footer StringLists For columns - Open the Column editor and click on each column name in the upper right field list In the object inspector, you can proerties for the data and title. Custom - entered in the <tr> tag FieldName - must match the name in the table Align - sets the horizontal alignment To change the color of a cell, setting Custom := '><font color=red' generates html like <td><font color=red>The data is here</td> And this generates a subscript in the title Caption := 'x<sub>0</sub>' This makes a data cell clickable - FormatCell is called for every cell TWebModule1.IR_Spectra_DataSetTableProducerFormatCell if (CellColumn = 1) and (CellRow > 0) then begin // Sample ID CellData := '<a href="IR_Spectra_Spectrum?ID='+CellData+ '" target="plot">' + CellData + '</a>'; end;


Data Modules

I had a great idea, place all database connections in Data Modules. They work great (and are easy to reuse) ... but there is a trick to use them in a web server. If you add one the normal way, you get this. Uh, this actually means that you can't have ANY Data Modules in web servers - the WebModule counts as the one and only allowed module. (Boy, that really sucks.)

This error is displayed when you try to display the page ... not when you build (compile and link) it. I tried changing the order of the CreateForm commands ... it had no effect.

However, placing this code in the WebModule works

I don't understand why

works, normally datamodules are initialized via which reads the *.dfm file. However, single stepping a program proves that TxyzDataModule.create works correctly.


Debug Details

To see the one data module per application error Simply running (double clicking) the file allows the window to close too soon to read the error.

This is the cryptic error displayed when you try to open a web page.

To fix this, remember to remove the datamodule from the *.dpr (project) file.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Databases / Delphi / WebServers / WebServer_Structure.html