We have already discussed how WOW and HSP can
work together in your Windows programs. Now lets
take it a step further. You can actually inject a
COM object into the HSP
programming scope, such that you can use it in the
VBScript/JScript code during the processing of your ASP
page. And amazingly, you can do the same thing with
.NET classes! The COM Interop service will transparently
create the COM interface for you.
can do this by using the HSP Server Object in your Application
code to "inject" an object into the Server.SessionVar collection where it can be used by
the ASP code. This collection is "static", meaning
that it exists for the lifetime of your application.
It allows you to provide your own COM object (must be
scriptable) or .NET class, either created by you (such as a VB Class or
Form object) or an existing COM object (such as an ADO
Connection or Recordset).
Here is an example of how to inject
an ADO Connection object. Suppose you have a global ADO
Connection object in your application, and you want to use
this same object in your ASP pages rather than create a new. This code would go in your VB
Dim hspServer as
'g_dbConn was created in your App's startup code
set hspServer.SessionVar("dbconn") = g_dbConn
Now you can access the Connection object in
the ASP code
Set cnn = Server("dbconn")
Now lets take a .NET example.
m_hsp = New
m_hsp.SessionVar("MyObj") = New MyDotNetClass()
Now you can access the .NET class object in
the ASP code just like any COM object:
Set myObj= Server("MyObj")