<% Set Session("Obj1") = Server.CreateObject("MyComponent.class1") %>
然后,您就可以在后面的 Web 页上调用 MyComponent.class1 揭示的方法和属性,其调用方法如下:
<% Session("Obj1").MyMethod %>
也可以通过展开该对象的本地副本并使用下列脚本来调用:
<%
Set MyLocalObj1 = Session("Obj1")
MyLocalObj1.MyObjMethod
%>
创建有会话作用域的对象的另一种方法是在 global.asa 文件中使用
<%
Set Session("var1") = Session
Set Session("var2") = Request
Set Session("var3") = Response
Set Session("var4") = Server
Set Session("var5") = Application
%>
<%
'Creating and initializing the array
Dim MyArray()
Redim MyArray(5)
MyArray(0) = "hello"
MyArray(1) = "some other
string
"
'Storing the array in the Session object
Session("StoredArray") = MyArray
Response.Re
dir
ect("file2.asp")
%>
---file2.asp---
<%
'Retrieving the array from the Session Object
'and mod
if
ying its second element
LocalArray = Session("StoredArray")
LocalArray(1) = " there"
'
print
ing out the string "hello there"
Response.Write(LocalArray(0)&LocalArray(1))
'Re-storing the array in the Session object
'This overwrites the values in StoredArray with the new values
Session("StoredArray") = LocalArray
%>
Run Behavior\BuildLiteBehavior [ RunTime:0.000011s ]
[ app_init ] --END-- [ RunTime:0.000054s ]
[ app_begin ] --START--
Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000060s ]
[ app_begin ] --END-- [ RunTime:0.000082s ]
[ view_parse ] --START--
[ template_filter ] --START--
Run Behavior\ContentReplaceBehavior [ RunTime:0.000141s ]
[ template_filter ] --END-- [ RunTime:0.000218s ]
Run Behavior\ParseTemplateBehavior [ RunTime:0.011140s ]
[ view_parse ] --END-- [ RunTime:0.011218s ]
[ view_filter ] --START--
Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000114s ]
[ view_filter ] --END-- [ RunTime:0.000193s ]
[ app_end ] --START--
1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= )