Lesson 6: Using ActiveX Server Components

The Server Object

The Server object accesses ActiveX components by using the CreateObject method. This object also enables you to set the timeout value of server-side scripts.

Syntax

Use the Server object with the following syntax:
 Server.  propertymethod  

To create an instance of an ActiveX server component, use the CreateObject method followed by the PROGID of the component. Use the ScriptTimeout property to set or determine the amount of time a server-side script runs before it times out and returns an error to the user .

Using the CreateObject Method

The first step in using an ActiveX server component is to create a reference to that component. Once you have created the reference, you can call the methods of the component or set and retrieve properties of the component.

You can also use the CreateObject method to create a reference to a Java class.

ActiveX controls run on the user's computer, while ActiveX server components reside and run on the Web server.

Example

This example creates a reference to the Browser Capabilities component.
 <% Set bc = Server.CreateObject("MSWC.BrowserType") %> 

ActiveX server components enable you to package and reuse common functions, such as accessing a database and writing information to text files on a Web server.

You can access the components installed on a Web server by using an .asp file with the CreateObject method of the Server object.

Using the ScriptTimeout Property

By default, a server-side script has 90 seconds to finish running. This does not include server-side script running an ActiveX server component. A server-side script will not time out while a server component is processing.

If the script takes longer to run than the default timeout set in the Windows registry, use the ScriptTimeOut property to change the timeout for that Active Server Page. This enables a large script to complete without timing out.

Example

This example uses the ScriptTimeout property of the Server object to increase the amount of time a script has to run before timing out:
 <% Server.ScriptTimeout = 180 'SECONDS %> 


Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net