Tutorial 1: Building a TurboHtml server using Indy.

This tutorial shows how to build a TurboHtml web application using Indy's HTTP Server component (TIdHttpServer).

There are five steps in this tutorial.

  1. Create a server.
  2. Connect a TurboHtml WebApp component.
  3. Create a page form.
  4. Connect the page to the server.
  5. Run the application and request the page from a browser.

1. Create a server.

Create a new standard application. Add a TidHttpServer to the main form.

Set the Active property to true.

Feedback buttonComponents can be added to the form to provide server controls or display statistics.


2. Connect a TurboHtml WebApp component.

Add a TTrbWebApp component (from the TrbWeb tab on the component palette). Add a TTrbIndyBridge component.

Set the HttpServer property of the TrbIndyBridge1 to IdHttpServer1.

Set the WebApp property to TrbWebApp1.

Feedback buttonEvery TurboHtml web application will use a TTrbWebApp component. The component has properties that control application features like session handling.

Feedback buttonBridge components connect TTrbWebApp components to transport mechanisms like Indy or WebSnap.


3. Create a page form.

Add a blank form to the project. We will call this form a page form because it will be displayed as a web page in the browser.

Add a TTrbWebForm component (from the TrboHtml tab on the component palette).

Add TurboHtml controls.

Make sure your page form is not auto-created.

Depending on your environment settings in Delphi, you may need to go into the Application Options and remove the page forms from the auto-create list (you can also remove the form create call from the application source file).

Feedback buttonEvery TurboHtml page form must have a TTrbWebForm component.

Feedback buttonYou can set the default page font with the PageFont property of the TTrbWebForm.

For this example, we added a TTrbLabel, set the Caption to "Hello World" and set the TrbWebForm1.PageFont to Arial 24.


4. Connect the page to the server.

On the main form, select TrbWebApp1, and activate the collection editor for the Pages property. Add a new page item.





Select the new TTrbAppPagesItem and switch to the Events tab of the inspector. Double-click the OnRequestFormClass event. Add code to the event as shown below. TPage1Form should correspond to the class of the form you created in Step 3.

Feedback buttonThe RequestFormClass event is required because there is no way to identify form classes in the inspector.

Add the unit for the page form to the implementation uses clause of the web module. The File|Use Unit... (Alt-F11) menu item can make this easier.


5. Run the application and request the page from a browser.

Compile and run the application. The server window appears.

Open a browser, and request the page: http://localhost

Feedback buttonThe URL may need to include a port number to correspond to the DefaultPort specified in the IdHttpServer in Step 1.

For our test application, DefaultPort was 90, so in the figure below the URL is: http://localhost:90