|
Tutorial
HSP
Now supports HTTP file downloads
You can now
specify a HTTP URL within the HSP URL. For example,
using this URL would download the file before running it:
x-hsp://www.sco.com/catalog.hsp
Server object and Session Variables Collection now
available from outside the scope of IE
The ASP Server object is designed to be a general
purpose utility object. We have extended it, adding many
Windows-centric methods and made it available to your
programs outside the scope of HSP. Now you can access both
the Server object and the Session Variable collection from
your programs that embed the Internet Explorer ActiveX
control (IEX). The Server object is implemented as a
"static" or "singleton" object and is
now available outside the scope of Internet Explorer. This
allows you to access the Server object within programs
that embed IEX controls for the purpose of
"injecting" objects and values into the HSP
environment to be available to your ASP pages.
As an example, suppose you have an application that
embeds IEX controls and uses HSP. And suppose that your
application uses and database and you keep a persistent
ADO connection in a global variable to be used throughout
your program. Rather than having to create new, separate
ADO Connection objects in your ASP pages every time they
run, you can inject the program's ADO object into the HSP
scope via the Server object's SessionVar property.
This is actually the same "Session Variables"
collection you access via the Session object in your ASP
pages.
Example. In your VB code, you have a global ADO
Connection object named "g_dbCnn", and an
embedded IEX control named "ieUserGroup". Here's
how you would use this feature.
Private Sub NavUserGroup()
Dim hspServer as new HSP.Server
set hspServer.SessionVar("dbconn") = g_dbCnn
ieUserGroup.Navigate "hsp://" & App.Path
& "/groups.hsp/usergroup.asp"
End Sub
Now the ADO Connection object is available in your ASP
pages in the "Session Variables" collection
until you remove it. Here is an example of accessing it:
Dim cnn as Connection
Set cnn = Session("dbconn")
...
To remove it from the collection you can either trap
the Internet Explorer (or WOW control) OnDocumentComplete
event in your application code, or you can do it in your
ASP code when finished with it in your cleanup code, as
follows.
Set Session("dbconn") = Empty
Of course, you can use this tech with any type of
object: Longs, strings or any COM objects. But
you cannot use VB clas objects with this mechanism
because HSP/IE is multi-threading and VB doesn't work in
such environments.
Server Events
Its often desirable to be able to call methods in a
containing application. If you are hosting the WOW or IE WebBrowser
component in your application and running ASP page with HSP, you may want to
call into your application code from script on an ASP page. We have
provided a mechanism to do this that works in all environments, including Visual
Basic.
We have added an events interface
to the Server object, so that you can call
Server.RaiseEvent in your script code and receive an
event in your application code. To do this you use the
Server object WithEvents in your VB code, and use
Server.RaiseEvent in your script code. Here is the COM
signature of the RaiseEvent event:
HRESULT OnRaiseEvent( [in] BSTR strEvent, [in] VARIANT
vtParam1, [in] VARIANT vtParam2, [in,out] VARIANT *pvtRet
)
So, in your script code you call it like this:
Dim retVal
Server.RaiseEvent "myEvent1", "param 1", "param 2", retVal
The first parameter is your the event identifier. This
is how your VB code can know which event is being
raised. The next two are optional paramters for the
event. And you can pass an "out" parameter in the last
param if you want to get a return value.
In your VB code you declare a HSP.Server object
Private WithEvents HSPServer As HSP.Server
In your code you create the object then you must call
Server.InitEvents
Set HSPServer = New HSP.Server
HSPServer.InitEvents
Then you bind to the Event and handle it according to
your needs.
Private Sub
HSPServer_OnRaiseEvent(ByVal
strEvent As String, ByVal vtParam1 As Variant, ByVal
vtParam2 As Variant, pvtRet As Variant)
if strEvent = "myEvent1" then
pvtRet =
"myEvent1 called"
end if
End Sub
Besides this cool feature, we have added many new
Windows-specific utility functions to the Server object.
Here is a list of some of the methods and properties of the Server
Object.
Methods:
URLEncode
MapPath
MapExternalPath
CreateObject
GetregValue
SetregValue
GetWindowsPath
GetEnv
DeleteRegValue
DeleteRegKey
ReadIniFileString
ReadIniFileLong
ReadIniFileSection
WriteIniFileString
WriteIniFileLong
WriteIniFileSection
Properties:
IsHSPFile
SessionVar
|