为了能够正常使用,必须把它们放到服务器上的一个虚拟应用程序内,并且把所提供的global.asa文件放到该应用程序的根目录中。最简单的办法是把global.asa文件放到缺省web网站的根目录(缺省情况下是c:/.netpub/wwwroot)中。
对任何已有的global.asa文件重命名是一个好办法,可以在以后对该文件进行恢复。
1. 显示application集合的内容
aspcounter对象是staticobjects集合的一个成员(通过<object>元素进行定义),但是其余部份(由server.createobject实例化)是contents集合的成员。
可以看到使用global.asa例子网页放到这些集合中的值,这在前面已经看到:
| <!-- declare instance of the aspcounter component with application-level scope //--> <object id=”aspcounter” runat=”server” scope=”applicatoin” progid=”mswc.counters”> </object> ... ... <script language=”vbscript” runat=”server”> sub application_onstart() ‘create an instance of an ado connection with application-level scope set application(“adoconnection”) = server.createobject(“adodb.connection”) dim vararray(3) ‘create a variant array and fill it vararray(0) = “this is a” vararray(1) = “variant array” vararray(2) = “stored in the” vararray(3) = “application object” application(“variant_array”) = vararray ‘store it in thd application application(“start_time”) = cstr(now) ‘store the date/time as a string application(“visit_count”) = 0 ‘set counter variable to zero end sub ... ... </script> |
| for each objitem in application.contents if isobject(application.contents(objitem)) then response.write “object reference: ‘” & objitem & “’ ” elseif isarray(application.contents(objitem)) then response.write “array: ‘” & objitem & “’ contents are: ” vararray = application.contents(objitem) ‘note: the following only works with a one-dimensional array for intloop = 0 to ubound(vararray) response.write “ index(“ & intloop & “) = “ & _ vararray(intloop) & “ ” next else response.write “variable: ‘” & objitem & “’ = “ _ & application.contents(objitem) & “ ” end if next |
| vararray = application.contents(objitem) |
| for intloop = 0 ubound(vararray) |
| for intloop = 0 to ubound(vararray) intnumberofdimensions = ubound(vararray, 1) for intdimension = 0 to intnumberofdimensions response.write “ index(“ & intloop & “) = “ _ & vararray(intloop, intdimension) next response.write “” next |
| for each objitem in application.staticobjects if isobject(application.staticobjects(objitem)) then response.write “<object> element: id=’” & objitem & “’ ” end if next |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器