ÓÐÕâÑùÒ»¸ö³ÌÐò£¬ÊǶÔApplication¼¯ºÏÖеÄÔªËØ½øÐлµÄÌí¼ÓÓëɾ³ý£¬³ÌÐòÈçÏ£º
<%@ LANGUAGE=VBSCRIPT %>
BODY {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
INPUT {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
The ASP Application Object
<% 'look for a command sent from the FORM section buttons
If Len(Request.Form("cmdAdd")) Then ' ÀûÓÃÊÇ·ñ³¤¶ÈΪ0À´ÅжÏ
strVarName = Request.Form("txtVarName")
strVarValue = Request.Form("txtVarValue")
Application.Lock
Application(strVarName) = strVarValue ' ´Ë´¦±¨´í
Application.Unlock
End If
If Len(Request.Form("cmdRemoveThis")) Then
strToRemove = Request.Form("lstRemove")
Application.Lock
Application.Contents.Remove(strToRemove)
Application.Unlock
End If
If Len(Request.Form("cmdRemoveAll")) Then
Application.Lock
Application.Contents.RemoveAll
Application.Unlock
End If
%>
<%
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
%>
<%
For Each objItem in Application.StaticObjects
If IsObject(Application.StaticObjects(objItem)) Then
Response.Write "
End if
Next
%>
Application.Lock
Application.Unlock
©1999 Wrox Press -
Professional ASP 3.0 (ISBN: 1-861002-61-0)
¸Ã³ÌÐòµÄ±¨´íÐÅÏ¢ÈçÏ£º
¼¼ÊõÐÅÏ¢£¨ÊÊÓÃÓÚÖ§³ÖÈËÔ±£©
¡¤ ´íÎóÀàÐÍ£º
Ó¦ÓóÌÐò¶ÔÏó, ASP 0102 (0x80004005)
º¯ÊýÐèÒª×Ö·û´®ÊäÈë¡£
/Chapter03/application/show_application.asp, µÚ 22 ÐÐ
¡¤ ä¯ÀÀÆ÷ÀàÐÍ£º
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; COM+ 1.0.2204)
¡¤ Ò³£º
POST 98 bytes to /Chapter03/application/show_application.asp
¡¤ POST Êý¾Ý:
cmdAdd=%A0%A0%
¡¤ A0&txtVarName=My_New_Value&txtVarValue=Testing%2C+testing+...&lstRemove=My_New_Value
¡¤ ʱ¼ä£º
2001Äê2ÔÂ16ÈÕ, 9:42:28
ÀµÆ¤ÔøÖ¸³öApplication(strVarName) = strVarValueӦΪApplication("strVarName") = strVarValue£¬ËäÈ»ÕâÑù×ö¿ÉÒÔͨ¹ý£¬µ«ÓÚ³ÌÐòµÄÔÒâ²»·û£¬³ÌÐòÒª×öµÄÊÇͨ¹ýRequest.Form¼¯ºÏÀ´»ñÈ¡¡£¶øÇÒ¼ÈÈ»ÊÇwroxµÄÀýÌ⣬Ӧ¸Ã²»Ì«»á³öʲôÎÊÌâ¡£
²½Öè1£ºÔÚ±¨´íµÄÉÏÒ»ÐмÓÈëResponse.Write("AAA")£¬Ä¿µÄÊǼìÑéIf ¡ ThenÓï¾äÊÇ·ñÆð×÷Ó㬽á¹û·¢ÏÖIf ¡ ThenÓï¾äÆð×÷Óõġ£
²½Öè2£º½«³ö´íµÄÒ»¾ä×¢Ê͵ô£¬²¢½«Response.Write("AAA")¸ÄΪ
Response.Write "strVarName = " & strVarName & "
"
Response.Write "strVarValue = " & strVarValue
½á¹ûΪ£ºstrVarName =
strVarValue = Testing, testing ...
Ϊʲô»ástrVarNameûÓÐÖµ£¬¶østrVarValueÈ´ÓÐֵĨ£¿Í¬Ñù¶¼ÊÇTextÊäÈë¿ò£¬È´»áÓв»Í¬µÄ½á¹û¡£·´¸´¹Û²ìºó£¬·¢ÏÖSubmitµÄֵΪ" "£¬¼´ÎªÈý¸ö¿Õ¸ñ£¬ÊÇ·ñ»áÓɿոñÒýÆðµÄÄØ£¿
²½Öè3£º±éÀúRequest.Form¼¯ºÏ£¬½«Á½¾äResponse.Write¸ú×Ù±äÁ¿Óï¾ä¸ÄΪ
For Each strName in Request.Form
Response.Write strName & " = " & Request.Form(strName) & "
"
Next
½á¹ûΪ£º
cmdAdd = ?txtVarName=My_New_Value
txtVarValue = Testing, testing ...
lstRemove = My_New_Value
¹ûÈ»ÊÇÓÉÓÚ¿Õ¸ñÔì³ÉµÄÂÒÂ룬¿ÉÕâÔ´³ÌÐòÊÇÀýÌ⣬²»Ó¦¸ÃÓдíѽ¡£Ïëµ½wroxÓõÄÊÇÓ¢ÎÄWindows 2000£¬ÎÒÓõÄÊÇÖÐÎÄ£¬ÄÇôӦ¸ÃÊÇÓÉË«×ֽڵĹØÏµ£¬¾ÍÓ¦¸ÃÐÞ¸ÄCODEPAGE¡£
¶øÎÒÍü¼ÇÁËÖÐÎÄCODEPAGEµÄ´úÂ룬ÔÚASP 3.0¸ß¼¶±à³ÌÖУ¬ÔøÐ´¹ýÈÕÎĵÄCODEPAGEΪ932£¬ÈÕÎÄÒ²Ó¦¸ÃÊÇË«×ֽڵġ£ËùÒÔ½«Ô´³ÌÐòµÄµÚÒ»ÐиÄΪ£º
<%@ LANGUAGE="VBSCRIPT" CODEPAGE="932" %>
³ÌÐòͨ¹ý£¡
ÕâÀïÏëÏò³õѧÕßÌá³öµÄÊÇ£¬×¢ÒâResponse.WriteºÍFor ¡ Each±éÀúÀ´¸ú×Ù±äÁ¿£¬ÕÒ³ö´íÎóµÄÔÒò£¬×¢ÒâË«×Ö½Ú¶Ô³ÌÐòµÄÓ°Ï죬»¹Óб¾ÎÄÖÐIf ¡ ThenÖеÄÅжÏÌõ¼þµÄ·½·¨¡£

