If you are using the Microsoft Internet Information Server (IIS) environment to serve your Web pages, you can use Active Server Pages (ASP) to create dynamic Web- based client-server applications. Active Server Pages allow you to embed controls in a Web page that get called every time the server loads the Web page. For example, you can write a Delphi Automation server, such as one to create a bitmap or connect to a database, and this control accesses data that gets updated every time the server loads the Web page.
Active Server Pages allow Web applications to be built using ActiveX server components (Automation objects). These are server-side components which you can develop using any Delphi or most other languages including C++, Java, Visual Basic. On the client side, the ASP is a standard HTML document and can be viewed by users on any platform using any Web browser.
Prior to this technology, client applications needed to be installed on every computer that would access the server. With this ASP model, most of the client application runs on the server; only the user interface presentation usually runs on the client. This makes it easier to update clients when an application changes.
You can also use Active Server Pages in conjunction with the Microsoft Transaction Server to automate the management of COM server components. For details on MTS, see "Creating MTS objects."
This chapter shows how to create an Active Server Page using the Delphi Active Server Page wizard. With this, you can expose properties and methods of an existing application for Automation control.
Here are the steps for creating an Active Server Page object from an existing application:
For more background on the COM technologies, see "Overview of COM technologies." For information about creating an Automation controller, see "Creating an Automation controller."
An Active Server Page object is an Automation object that has access to the interfaces of a Web request. Like other Automation objects, it is an ObjectPascal class descending from TAutoObject that supports Automation protocols, exposing itself for other applications to use. You create an Active Server Page object using the Active Server Object wizard.
Before you create an Active Server Page object, create or open the project for an application containing functionality that you want to expose. The project can be either an application or ActiveX library, depending on your needs.
You can use Server.CreateObject in an ASP page to launch either an in-process or out-of-process server, depending on your requirements. However, you should be aware of the drawbacks of launching an out-of-process server.
To display the Active Server Object wizard:
In the wizard, specify the following:
Specify the class whose properties and methods you want to expose to client applications. (Delphi prepends a T to this name.) | |
Specify an instancing mode to indicate how your Active Server Page object is launched. For details, see"COM object instancing types". Note: When your Active Server Page object is used only as an in-process server, instancing is ignored. | |
Choose the threading model to indicate how client applications can call your object's interface. This is the threading model that you commit to implementing in the Active Server Page object. For more information on threading models, see"Choosing a threading model". Note: The threading model you choose determines how the object is registered. You must make sure that your object implementation adheres to the model selected. | |
Choose Page Level Event Methods with IIS 3 and IIS 4. It creates an Active Server Page object that implements the methods, OnStartPage and OnEndPage. These methods are called by the Web server when the page initializes and finishes execution. Use this with IIS 3 and IIS 4. Choose Object Context with IIS 5. It uses the functionality of MTS to retrieve the correct instance data of your object. | |
Generate a simple .ASP page which creates the Delphi object based off its ProgID. | |
Check this box to tell the wizard to implement a separate interface for managing events of your Active Server Page object. For more information on managing events, see "Managing events in your Automation object". |
When you complete this procedure, a new unit is added to the current project that contains the definition for the Active Server Page object. In addition, the wizard adds a type library project and opens the type library. Now you can expose the properties and methods of the interface through the type library as described in "Exposing an application's properties, methods, and events".
The Active Server Page object, like any other Automation object, implements a dual interface, which supports both early (compile-time) binding through the VTable and late (runtime) binding through the IDispatch interface. For more information on dual interfaces, see "Dual interfaces".
You can use Server.CreateObject in an ASP page to launch either an or server, depending on your requirements. However, launching in-process servers is more common.
In-process component DLLs are faster, more secure, and can be hosted by MTS, so they are better suited for server-side use.
Because out-of-process servers are less secure, it is common for IIS to be configured to not allow out-of-process executables. In this case, you would receive an error similar to the following:
Server object error 'ASP 0196' Cannot launch out of process component /path/outofprocess_exe.asp, line 11
Also, out-of-process components often create individual server processes for each object instance, so they are slower than CGI applications. They do not scale as well as component DLLs that run in-process with IIS or MTS. If performance and scalability are priorities for your site, we recommend that you do not use out-of-process components.
However, intranet sites that receive moderate to low traffic might be able to use an out-of-process component without adversely affecting the site's overall performance.
For general information on in-process and out-of-process servers, see "In-process, out-of-process, and remote servers".
You can register the Active Server Page as an in-process or an out-of-process server. However, in-process servers are more common.
Note: When you want to remove the Active Server Page object from your system, it is recommended that you first unregister it, removing its entries from the Windows registry.
To register an in-process server (DLL or OCX),
To unregister an in-process server,
To register an out-of-process server,
To unregister an out-of-process server,
Debugging any in-process server such as an Active Server Page is much like debugging a DLL. You choose a host application that loads the DLL, and debug as usual. To test and debug an Active Server Page object,
The Active Server Page pauses when the breakpoints are reached.
pubsweb@inprise.com
Copyright © 1999, Inprise Corporation. All rights reserved.