5、 雙擊JavaASP.Java,會出現一個代碼框,把下面的代碼輸入代碼框,並保存。
import com.ms.IIS.ASP.*;
import com.ms.mtx.*;
這兩句應當出現在程序的最前面,它們是導入命令,導入我們在工程中需要用到的某些Java類的包,我下面給出完整的程序
/** * This class is designed to be packaged with a COM DLL output format. * The class has no standard entry points, other than the constructor. * Public methods will be exposed as methods on the default COM interface. * @com.register ( clsid=ADE14872-9CF6-42A0-A8F2-7A571E51A840, typelib=5E11D496-7229-4283-A40B-139E05DEF44C ) */ //上面我們看到一個clsid,它是用來標記微軟COM組件所用的。
import com.ms.IIS.ASP.*;//導入兩個包
import com.ms.mtx.*;
public class JavaASP
{
public boolean HelloWorld()
{
Response newRes = ASPContext.getResponse();//創建一個Response
newRes.write("Hello World,Maybe it is your first JavaASP COM!");
return true;
}
}