Creating Script Components for ASP
You implement your design as a scriptlet by creating an XML file, which is much like an HTML file, but contains special elements that define the scriptlet and its behavior. The elements used for defining script components are not standard HTML tags. Instead, they are XML elements that are specifically used for scriptlet definitions.
When defining a scriptlet, you create these elements:
Scriptlet element: An element that encloses the entire scriptlet definition.
Registration element: An element that includes information used to register your scriptlet as a COM automation component.
Implements element: An element that specifies the COM interface handler for the scriptlet, which determines what type of COM component the scriptlet will be. For example, for script components that you develop to be called by ASP, you should specify that the scriptlet implements the Automation handler, which allows your scriptlet to be used as a COM automation component. Inside the Implements element, you specify information specific to the interfaces you are implementing. In the case of a COM Automation component, for example, you specify the methods and properties that your scriptlet will make available.
Script element: An element containing the script used to implement the logic of your scriptlet. The types of script you write depends on what type of COM component you are creating. If you are creating a COM automation component, for example, you implement your scriptlet's methods and properties in the SCRIPT element.
To access the ASP built-in objects in a script component (scriptlet)
Create an instance of the MTxAS.AppServer.1 object.
Create an object that is bound to the COM+ ObjectContext object by calling the GetObjectContext function. This is necessary because the scriptlet will not be compiled until your ASP page calls it.
The following example code shows you how to use the VBScript programming language to bind an object to the COM+ ObjectContext object and using the bound object to access the Response object.
The following example demonstrates using a scriptlet to send a response to the client.
<scriptlet> <Registration Description="Writer" ProgID="Writer.Scriptlet" Version="1.00"> </Registration> <implements id=Automation type=Automation> <method name=sendResponse> </method> </implements> <script Language= "VBScript"> function sendResponse() Dim objCurr Dim objCurrObjCont Dim vntResp Set objCurr = CreateObject("MTxAS.AppServer.1") Set objCurrObjCont = objCurr.GetObjectContext() vntResp = objCurrObjCont("Response").Write ("Hello World") end function </scriptlet>