To use Server.CreateObject to create an instance of a Java class, you must
use the JavaReg program to register the class as a COM component. You can then
use Server.CreateObject
method or an HTML <OBJECT>
tag with the PROGID or CLSID. Alternatively, you can use the mechanism provided
by Java monikers to instantiate the Java class directly without using the JavaReg
program. To instantiate a class with monikers, use the VBScript or JScript GetObject
statement and provide the full name of the Java class in the form java:classname.
The following VBScript example creates an instance of the Java Date class.
<%
Dim dtmDate
Set dtmDate = GetObject("java:java.util.Date")
Response.Write "The date is " & dtmDate.toString()
%>
Objects created by calling GetObject
instead of Server.CreateObject
can also access the ASP built-in objects and participate in a transaction. To
use Java monikers, however, you must be using version 2.0, or later, of the Microsoft
virtual machine.
Comments