当前位置: 首页 > 图文教程 > 网络编程 > ASP > 手把手教你使用Java来编写ASP组件(2)

ASP
深入研究Application和Session对象(2)
深入研究Application和Session对象(3)
开始 .Net的旅程(一)
开始 .Net的旅程(二)
手把手教你使用VB来创建ASP组件(1)
手把手教你使用VB来创建ASP组件(2)
手把手教你使用VB来创建ASP组件(3)
手把手教你使用VB来创建ASP组件(4)
手把手教你使用VB来创建ASP组件(5)
手把手教你使用VB来创建ASP组件(6)
手把手教你使用VB来创建ASP组件(7)
手把手教你使用Java来编写ASP组件(1)
手把手教你使用Java来编写ASP组件(2)
手把手教你使用Java来编写ASP组件(3)
手把手教你使用Java来编写ASP组件(4)
手把手教你使用Java来编写ASP组件(5)
手把手教你使用Java来编写ASP组件(6)
ASP 3.0高级编程(二十四)
ASP 3.0高级编程(二十五)
ASP 3.0高级编程(二十六)

手把手教你使用Java来编写ASP组件(2)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 20 ::
收藏到网摘: n/a

  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;
 }