iiChapter 3 Using the ILS ActiveX Server Component With Active Server Pages
To use ILS, you will use the Active Server Pages script processor and its collection of objects and components, as well as the ILS ActiveX server component. This chapter provides the information needed for using the ILS component in Active Server Pages scripts.
All pages that use scripting must use the .asp file name extension, and must be in a virtual root on your Web server that has both read and execute permission.
You must create an instance of each ActiveX server component you use in each HTML page that uses the component. When you create the instance, the server component executes commands to initialize itself. You must also create a variable for this instance of the server component. This variable is used when you call the methods and properties of the server component. You choose the variable name to use in your script.
Creating an instance of the object and assigning a variable are both done in one statement in your .asp page:
<% set variable = Server.CreateObject ("component_identifier") %>
The component identifier for ILS is ms.ils.
For example, to create a reference to the ILS component in your script, you could use the following line to create a variable called ils.
<% set ils = Server.CreateObject("ms.ils") %>
The object creation statement must precede use of the component.
When a script completes, the instance of the object is removed from memory.
To refer to an ILS database attribute in a script, you use VBScript syntax to refer to the attribute as a property of the created object. For instance, the example below shows the location of a user:
<% = ils.location %>
Components have both methods and properties. Methods take parameters while properties can be either read or set.
When you use a method or property, you prefix it with the variable name you defined when you created the instance of the object using Server.CreateObject. For example, the Error property shows the error code. To display the error code, you would use this line:
<% = ils.error %>
You can nest calls inside methods. In the following example, the call to the Active Server Pages Request object is nested inside the call to the Find method.
<% ils.find(Request.form)%>
Complete syntax information can be found in the online Active Server Pages Roadmap provided with the Internet Information Server version 3.0 upgrade.
There are several key syntax issues to note:
For complete comment lines, use
<% REM Comment here. %>
Comments can also be inserted in the middle of a script by using a single quote. For example,
<% if ils.gna = "" then 'first name is blank %>
<% = ils.fna %>
Whenever you use any of the components in a script, you must be prepared for errors. Checking for error conditions in your scripts is critical for the user to have a good experience.
There are several error handling issues to consider in all scripts:
<% on error resume next %>
<% on error resume next %>
<% set ils = Server.CreateObject("ms.ils") %>
<% if IsObject(ils) = FALSE then %>
ILS is not installed correctly on this server.
<% else %>
Rest of page here.
<% end if %>
<% createresult = ils.create(Request.form) %>
<% if ( createresult <> "WPQR_SUCCESS" ) then %>
Your listing was not created due to the following error:
<%=ils.error %>.
<% end if %>
<% if Request("cna") = Empty then %>
You must provide your e-mail name to delete your listing.
<% else %>
<%ils.delete(Request.form)%>
<% end if %>
For example:
<% if Request("Content_Length") > 0 then %>
Show online users.
<% else %>
Provide form to collect user's information.
<% end if %>