手把手教你使用Java来编写ASP组件(2)
程序员文章站
2024-01-29 20:57:40
5、 双击javaasp.java,会出现一个代码框,把下面的代码输入代码框,并保存。
import com.ms.iis..*;
import com.ms.mt...
5、 双击javaasp.java,会出现一个代码框,把下面的代码输入代码框,并保存。
import com.ms.iis..*;
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;
}
}
import com.ms.iis..*;
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;
}
}