Global asa v Event handlers ApplicationOn Start v
Global. asa v 이벤트 핸들러(Event handlers) Application_On. Start v Session_On. End v Application_On. End v Transparency No. 1 -2 -5
Application 및 Session객체(5/16) v Global. asa <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> SUB Application_On. Start Application("Greeting") = "안녕하세요. . . " Application("User. Addr") = "원격지" END SUB Application_On. End END SUB Session_On. Start END SUB Session_On. End END SUB </SCRIPT> … <H 2> Global. asa 이용 </H 2> <%= Application("Greeting") + "<P>" + Application("User. Addr") + "에서 오신 고객님의 방 문을 환영합니다. " %> … Transparency No. 1 -2 -9
Application 및 Session객체(6/16) v Global. asa 파일에서 Application 객체의 변수를 사용하는 방법 <Script Language="VBScript" Runat="Server"> Sub Application_On. Start Application("변수명") = "값" Application("변수명") = 값 End Sub </Script> <% Response. Write(Application("변수명")) %> Transparency No. 1 -2 -10
Application 및 Session객체(7/16) v Contents 컬렉션 v Application 객체에 저장되어 있는 변수의 값을 파악 <SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER"> Sub Session_On. Start Application. Lock Application("visitors") = Application("visitors") + 1 Application("Hello") = "Hello " Application("World") = "World !!!" Application. Unlock End Sub Session_On. End Application. Lock Application("visitors") = Application("visitors") - 1 Application. Unlock End Sub </SCRIPT> Transparency No. 1 -2 -11
v v v <% For Each i in Application. Contents Response. Write i & " : " Response. Write(Application. Contents(i) & "<P>") Next %> Transparency No. 1 -2 -12
Application 및 Session객체(8/16) v Count 속성 v Contents 컬렉션에 저장되어 있는 항목의 수를 나타 내 주는 속성 … <BODY> <B> Contents 콜렉션을 이용한 어플리케이션 변수의 값 출력 </B> <HR> 현재의 접속자 수 : <%= Application("visitors") & "<HR>" %> <% For Each i in Application. Contents Response. Write i & " : " Response. Write Application. Contents(i) & "<P>" Next %> <HR> Count 속성을 사용하여 Contents 콜렉션의 내용을 출력 <HR> <% j=Application. Contents. Count Response. Write "Contents 콜렉션에는 " & j & " 개의 항목이 있습니다. " & "<P>" For i=1 to j Response. Write (Application. Contents(i) & " ") Next %> Transparency No. 1 -2 -13 </BODY>
Application 및 Session객체(9/16) v Static. Objects 컬렉션 v Application 객체에 저장된 모든 객체의 값을 가지는 컬렉션 <% Dim i For Each i in Application. Static. Objects Response. Write(Application. Static. Objects(i) & "<P>") Next %> Transparency No. 1 -2 -14
v v v … <% Application. Lock %> … <% v Application. Unlock v %> v … v Transparency No. 1 -2 -16
Application 및 Session객체(13/16) v Contents 컬렉션 v Session 객체의 모든 변수를 가지는 컬렉션 <% For Each i in Session. Contents Response. Write Session. Contents(i) & "<P>" Next %> v Remove/Remove. All 메소드 v Session 객체의 변수를 제거 <% If Session. Contents("Lower. Bound") < 100 then Session. Contents. Remove("Average") End If %> Transparency No. 1 -2 -19
Application 및 Session객체(14/16) v Count 속성 v Contents 컬렉션에 저장되어 있는 항목의 수를 알려 주는 속성 … <% j=Session. Contents. Count Response. Write "Session 변수 : " & j For i=1 to j Response. Write Session. Contents(i) & "<P>") Next %> … Transparency No. 1 -2 -20
Application 및 Session객체(15/16) v Static. Objects 컬렉션 v Session 객체에 저장되어 있는 모든 객체의 값을 가 지는 컬렉션 … <% For Each i in Session. Static. Objects Response. Write Session. Static. Objects(i) & "<P>" Next %> … Transparency No. 1 -2 -21
Application 및 Session객체(16/16) v Session. ID 속성 연결된 세션에 관한 ID를 가지는 속성 v ID v 해당 세션에 대하여 서버가 만들어 주는 고유한 식별자 v LONG 서브타입 v <HTML> <HEAD><TITLE> Session ID </TITLE> </HEAD> <BODY> <B> 세션 ID 알아내기</B> <P> 현재 세션의 ID는 <BR> <% Response. Write(Session. ID) %> <BR> 입니다. </BODY> </HTML> Transparency No. 1 -2 -22
v v v v v … <% int. Tout = Request("timeout") Server. Script. Timeout = int. Tout %> <BR><B> <%= "변경된 Script. Timeout : "%> <%= Server. Script. Timeout %> … Transparency No. 1 -2 -24
… <FORM method="post" action="Server_URLEncode. asp"> <P> <BR><B> 인코딩할 문자 : </B> <INPUT name="subject" size=30 value=" ~ ! @ # $ % ^ " > </P> <INPUT type="submit" name="submit" value="URLEncode 메소드 결과보기"> <INPUT type="submit" name="reset" value="초기설정"> </FORM> <BR> <P> ******************************* <BR> URLEncode 메소드에 의해 인코딩된 문자열 <BR> ******************************* </P> <% Response. Write Server. URLEncode(Request("subject")) %> … Transparency No. 1 -2 -27
"/"의 절대 경로 : <% Response. Write Server. Map. Path("/") %> <P> "/chs/"의 절대 경로 : <% Response. Write Server. Map. Path("/chs/") %> <P> 이 파일의 가상 경로 : <% Response. Write Request. Server. Variables("URL") %> <P> 이 파일의 절대 경로 : <% Response. Write Server. Map. Path(Request. Server. Variables("URL")) %> Transparency No. 1 -2 -29
"/"의 절대 경로 : <% Response. Write Server. Map. Path("/") %> <P> "/chs/"의 절대 경로 : <% Response. Write Server. Map. Path("/chs/") %> <P> 이 파일의 가상 경로 : <% Response. Write Request. Server. Variables("URL") %> <P> 이 파일의 절대 경로 : <% Response. Write Server. Map. Path(Request. Server. Variables("URL")) %> Transparency No. 1 -2 -31
- Slides: 31