ASP Contents 집합

Application 객체 참조 가이드

Contents 집합은 스크립트 명령으로 application/session에 추가된 모든 항목을 포함하고 있습니다.

훌륭합니다:Contents 집합에서 항목을 제거하려면 Remove 및 RemoveAll 메서드를 사용하십시오.

문법

Application.Contents(Key)
Session.Contents(Key)
파라미터 설명
key 필수. 가져오려는 항목의 이름.

Application 객체의 인스턴스에 대한

예제 1

주의하세요, name 과 objtest 모두 Contents 집합에 추가됩니다:

<% 
Application("name")="W3School"
Set Application("objtest")=Server.CreateObject("ADODB.Connection")
%>

예제 2

Contents 집합을 순회합니다:

<%
for each x in Application.Contents
  Response.Write(x & "=" & Application.Contents(x) & "<br />")
next
%>

또는:

<%
For i=1 to Application.Contents.Count
  Response.Write(i & "=" & Application.Contents(i) & "<br />")
Next
%>

예제 3

<%
Application("date")="2001/05/05"
Application("author")="W3School"
for each x in Application.Contents
  Response.Write(x & "=" & Application.Contents(x) & "<br />")
next
%>

출력:

date=2001/05/05
author=W3School

Session 객체의 인스턴스에 대한

예제 1

주의하세요, name 과 objtest 모두 Contents 집합에 추가됩니다:

<% 
Session("name")="Hege"
Set Session("objtest")=Server.CreateObject("ADODB.Connection")
%>

예제 2

Contents 집합을 순회합니다:

<%
for each x in Session.Contents
  Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
%>

또는:

<%
For i=1 to Session.Contents.Count
  Response.Write(i & "=" & Session.Contents(i) & "<br />")
Next
%>

예제 3

<%
Session("name")="Hege"
Session("date")="2001/05/05"
for each x in Session.Contents
  Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
%>

출력:

name=Hege
date=2001/05/05

Application 객체 참조 가이드