RAD Studio |  |

Types of Web Server Applications
ISAPI and NSAPI | CGI stand-alone | Apache | Web App Debugger | Converting Web server application target types | See Also
Collapse All

Whether you use Web Broker or WebSnap, you can create five standard types of Web server applications. In addition, you can create a Web Application Debugger executable, which integrates the Web server into your application so that you can debug your application logic. The Web Application Debugger executable is intended only for debugging. When you deploy your application, you should migrate to one of the other five types.

ISAPI and NSAPI

An ISAPI or NSAPI Web server application is a DLL that is loaded by the Web server. Client request information is passed to the DLL as a structure and evaluated by the ISAPI/NSAPI application, which creates appropriate request and response objects. Each request message is automatically handled in a separate execution thread.

CGI stand-alone

A CGI stand-alone Web server application is a console application that receives client request information on standard input and passes the results back to the server on standard output. This data is evaluated by the CGI application, which creates appropriate request and response objects. Each request message is handled by a separate instance of the application.

Apache

An Apache Web server application is a DLL that is loaded by the Web server. Client request information is passed to the DLL as a structure and evaluated by the Apache Web server application, which creates appropriate request and response objects. Each request message is automatically handled in a separate execution thread. You can build your Web server applications using Apache 1 or 2 as your target type.

When you deploy your Apache Web server application, you will need to specify some application-specific information in the Apache configuration files. For example, in Apache 1 projects the default module name is the project name with _module appended to the end. For example, a project named Project1 would have Project1_module as its module name. Similarly, the default content type is the project name with -content appended, and the default handler type is the project name with-handler appended.

These definitions can be changed in the project (.dpr) file when necessary. For example, when you create your project a default module name is stored in the project file. Here is a common example:

Copy Code

    exports
    apache_module name 'Project1_module';

Copy Code

    extern "C"
    {
    Httpd::module __declspec(dllexport) Project1_module;
    }

Note: When you rename the project during the save process, that name isn't changed automatically. Whenever you rename your project, you must change the module name in your project file to match your project name. The content and handler definitions should change automatically once the module name is changed.
For information on using module, content, and handler definitions in your Apache configuration files, see the documentation on the Apache Web site httpd.apache.org.
Web App Debugger

The server types mentioned above have their advantages and disadvantages for production environments, but none of them is well-suited for debugging. Deploying your application and configuring the debugger can make Web server application debugging far more tedious than debugging other application types.

Fortunately, Web server application debugging doesn't need to be that complicated. The IDE includes a Web App Debugger which makes debugging simple. The Web App Debugger acts like a Web server on your development machine. If you build your Web server application as a Web App Debugger executable, deployment happens automatically during the build process. To debug your application, start it using RunRun. Next, select ToolsWeb App Debugger, click the default URL and select your application in the Web browser which appears. Your application will launch in the browser window, and you can use the IDE to set breakpoints and obtain debugging information.

When your application is ready to be tested or deployed in a production environment, you can convert your Web App Debugger project to one of the other target types using the steps given below.

Note: When you create a Web App Debugger project, you will need to provide a CoClass Name for your project. This is simply a name used by the Web App Debugger to refer to your application. Most developers use the application's name as the CoClass Name.
Converting Web server application target types

One powerful feature of Web Broker and WebSnap is that they offer several different target server types. The IDE allows you to easily convert from one target type to another.

Because Web Broker and WebSnap have slightly different design philosophies, you must use a different conversion method for each architecture.

To convert your Web Broker application target type

1. Right-click the Web module and choose Add To Repository.
2. In the Add To Repository dialog box, give your Web module a title, text description, Repository page (probably Data Modules), author name, and icon.
3. Choose OK to save your Web module as a template.
4. From the main menu, choose FileNew and select Web Server Application. In the New Web Server Application dialog box, choose the appropriate target type.
5. Delete the automatically generated Web module.
6. From the main menu, choose FileNew and select the template you saved in step 3. This will be on the page you specified in step 2.

To convert a WebSnap application's target type

1. Open your project in the IDE.
2. Display the Project Manager using ViewProject Manager. Expand your project so all of its units are visible.
3. In the Project Manager, click the New button to create a new Web server application project. Double-click the WebSnap Application item in the WebSnap tab. Select the appropriate options for your project, including the server type you want to use, then click OK.
4. Expand the new project in the Project Manager. Select any files appearing there and delete them.
5. One at a time, select each file in your project (except for the form file in a Web App Debugger project) and drag it to the new project. When a dialog appears asking if you want to add that file to your new project, click Yes.

See Also

Creating Web Server Applications

The Structure of a Web Broker Application

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!