<%@ LANGUAGE="VBSCRIPT" %>
<!--#INCLUDE FILE="adovbs.inc"-->
<%
'************************************************************************
'* *
'* ASP Objects: *
'* Application Response Session *
'* Request Server *
'* *
'************************************************************************
'************************************************************************
'* *
'* Application Object: *
'* *
'* Methods: *
'* Lock Unlock *
'* *
'* Events: *
'* Application_OnEnd Application_OnStart *
'* *
'************************************************************************
Application("TestVar") = 3.14 ' Create/Modify a variable with application scope
' Lock method prevents other clients from modifying Application object properties.
Application.Lock
Application("NumVisits") = Application("NumVisits") + 1
Application.Unlock
' Events must be placed in global.asa to run
'Sub Application_OnStart
'End Sub
'Sub Application_OnEnd
'End Sub
'************************************************************************
'* *
'* Session Object: *
'* *
'* Properties: *
'* SessionID Timeout *
'* *
'* Methods: *
'* Abandon *
'* *
'************************************************************************
Session("TestVar") = 3.14 ' Create/Modify a variable with session scope
' Returns the session identification for this user.
i = Session.SessionID
' The timeout period for the session state for this application, in minutes.
Session.Timeout = 60
' This method destroys a Session object and releases its resources.
'Session.Abandon
'************************************************************************
'* *
'* Response Object: *
'* *
'* Collections: *
'* Cookies *
'* *
'* Properties: *
'* Buffer Expires Status *
'* ContentType ExpiresAbsolute *
'* *
'* Methods: *
'* AddHeader Clear Redirect *
'* AppendToLog End Write *
'* BinaryWrite Flush *
'* *
'************************************************************************
'Response.Redirect("hello.html") ' redirect to a different URL
Response.ContentType ' HTTP content type for the response
Response.Expires = 0 ' time before page cached on browser expires (immediate=0)
' note: Expires=0 causes grief with Netscape Printing
Response.ExpiresAbsolute = Now() ' date/time a page cached on a browser expires
Response.AddHeader "Pragma", "No-Cache" ' sets the HTML header name to value
' note: this pragma tries to disable caching
'Response.Status = "401 Unauthorized" ' status returned by the server
' write out cookies
Response.Cookies("urCookie") = "ABCD" ' assign single value to cookie
Response.Cookies("myCookie")("key1") = "AB" ' assign key/value pairs
Response.Cookies("myCookie")("key2") = "CD"
Response.Cookies("urCookie").Expires = "July 31, 2000"
Response.Cookies("urCookie").Domain = "dascon1"
Response.Cookies("urCookie").Path = "/www/"
Response.Cookies("urCookie").Secure = FALSE
For Each cookie in Response.Cookies
If (Response.Cookies(cookie).HasKeys) Then
For Each key in Response.Cookies(cookie)
Response.Cookies(cookie)(key) = "AB"
Next
Else
Response.Cookies(cookie) = "ABCD"
End If
Next
'Response.Buffer = True ' indicates whether page output is buffered
'Response.Flush ' sends buffered output immediately
'Response.Clear ' erases any buffered HTML output
'Response.Write("Hello") ' writes to HTTP output as a string
'Response.AppendToLog "Hello Log" ' writes a Web server log entry
'Response.End ' stops processing the .asp file
'???Response.BinaryWrite ' write binary output from generator
'************************************************************************
'* *
'* Server Object: *
'* *
'* Properties: *
'* ScriptTimeout *
'* *
'* Methods: *
'* CreateObject MapPath URLEncode *
'* HTMLEncode *
'* *
'************************************************************************
Server.ScriptTimeOut = 20 * 60 ' timeout used for ASP script (20 minutes)
x = Server.HTMLEncode("http://www.halliburton.com/") ' applies HTML encoding to the specified string
x = Server.URLEncode("<>""&") ' applies URL encoding rules
x = Server.MapPath("hello.asp") ' physical path of the file
x = Server.MapPath("/") ' root directory
x = Server.MapPath("./") ' current directory
Set Db = Server.CreateObject("ADODB.Connection") ' Create the object used for database connection
Set bc = Server.CreateObject("MSWC.BrowserType") ' Browser Capabilities Component
x = bc.browser ' browser name
x = bc.version ' version number
x = bc.frames ' frames supported
x = bc.tables ' tables supported
x = bc.BackgroundSounds ' sound supported
x = bc.vbscript ' vbscript supported
x = bc.javascript ' javascript supported
' Note: this component uses Browscap.ini to give answers - gives Unknown answers for unregistered browser
'************************************************************************
'* *
'* Request Object: *
'* *
'* Collections: *
'* ClientCertificate Form ServerVariables *
'* Cookies QueryString *
'* *
'************************************************************************
If (Not (IsEmpty(Request("SubmitButton")))) Then
If (Request.ServerVariables("REQUEST_METHOD") = "POST") Then
x = Request.Form("SubmitButton")
Else
x = Request.QueryString("SubmitButton")
End If
x = Request("SubmitButton")
If (Request.ServerVariables("REQUEST_METHOD") = "POST") Then
For Each item In Request.Form
x = Request.Form(item)
Next
Else
For Each item In Request.QueryString
x = Request.QueryString(item)
Next
End If
End If
' access server variables individually
x = Request.ServerVariables("AUTH_TYPE") ' authentication method used to validate users
x = Request.ServerVariables("CONTENT_LENGTH") ' length of the content as given by the client
x = Request.ServerVariables("CONTENT_TYPE") ' data type of the content
x = Request.ServerVariables("GATEWAY_INTERFACE") ' CGI revision specification used by the server
x = Request.ServerVariables("HTTP_ACCEPT")
x = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
x = Request.ServerVariables("HTTP_CONNECTION")
x = Request.ServerVariables("HTTP_CONTENT_LENGTH")
x = Request.ServerVariables("HTTP_CONTENT_TYPE")
x = Request.ServerVariables("HTTP_HOST")
x = Request.ServerVariables("HTTP_REFERER")
x = Request.ServerVariables("HTTP_ACCEPT_ENCODING")
x = Request.ServerVariables("HTTP_USER_AGENT")
x = Request.ServerVariables("HTTP_COOKIE")
x = Request.ServerVariables("LOGON_USER") ' NT account that the user is logged into
x = Request.ServerVariables("PATH_INFO") ' path information as given by the client
x = Request.ServerVariables("PATH_TRANSLATED") ' physical path information
x = Request.ServerVariables("QUERY_STRING") ' query information stored in URL (get)
x = Request.ServerVariables("REMOTE_ADDR") ' IP address of the remote host making the request
x = Request.ServerVariables("REMOTE_HOST") ' name of the host making the request
x = Request.ServerVariables("REQUEST_METHOD") ' method used to make the request (GET, HEAD, POST)
x = Request.ServerVariables("SCRIPT_MAP") ' base portion of the URL
x = Request.ServerVariables("SCRIPT_NAME") ' virtual path to the script being executed
x = Request.ServerVariables("SERVER_NAME") ' serve name, DNS alias, or IP address
x = Request.ServerVariables("SERVER_PORT") ' port number to which the request was sent
x = Request.ServerVariables("SERVER_PORT_SECURE") ' flag for secure port (0 or 1)
x = Request.ServerVariables("SERVER_PROTOCOL") ' http protocol/revision
x = Request.ServerVariables("SERVER_SOFTWARE") ' name and version of the server software
x = Request.ServerVariables("URL") ' base portion of the URL.
' The values of predetermined environment variables.
For Each key In Request.ServerVariables
'Response.Write key & "=" & Request.ServerVariables(key) & "<br>"
Next
' Server Variables:
' AUTH_TYPE=
' CONTENT_LENGTH=38
' CONTENT_TYPE=application/x-www-form-urlencoded
' GATEWAY_INTERFACE=CGI/1.1
' LOGON_USER=
' PATH_INFO=/test/hello.asp
' PATH_TRANSLATED=D:\InetPub\wwwroot\test\hello.asp
' QUERY_STRING=
' REMOTE_ADDR=34.2.21.144
' REMOTE_HOST=34.2.21.144
' REQUEST_METHOD=POST
' SCRIPT_MAP=
' SCRIPT_NAME=/test/hello.asp
' SERVER_NAME=dccntdbd
' SERVER_PORT=80
' SERVER_PORT_SECURE=0
' SERVER_PROTOCOL=HTTP/1.1
' SERVER_SOFTWARE=Microsoft-IIS/3.0
' URL=/test/hello.asp
' HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
' application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
' HTTP_ACCEPT_LANGUAGE=en-us
' HTTP_CONNECTION=Keep-Alive
' HTTP_CONTENT_LENGTH=38
' HTTP_CONTENT_TYPE=application/x-www-form-urlencoded
' HTTP_HOST=dccntdbd
' HTTP_REFERER=http://dccntdbd/test/hello.asp
' HTTP_ACCEPT_ENCODING=gzip, deflate
' HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
' HTTP_COOKIE=MYCOOKIE=KEY1=AB&KEY2=AB; ASPSESSIONID=QWWNJOMYGIPZUYJN
' The values of cookies sent in the HTTP request.
For Each cookie in Request.Cookies
If (Request(cookie).HasKeys) Then
For Each key in Request.Cookies(cookie)
s = s & cookie & "." & key & "=" & Request.Cookies(cookie)(key) & "<br>"
Next
Else
s = s & cookie & "=" & Request.Cookies(cookie) & "<br>"
End If
Next
' The values of fields stored in the client certificate that is sent in the HTTP request.
For Each key in Request.ClientCertificate
Response.Write(key & ": " & Request.ClientCertificate(key) & "<BR>")
Next
x = Request.ClientCertificate("Subject") ' comma-separated list of subfields 'C=US, O=Msft, ...'
x = Request.ClientCertificate("Issuer") ' issuer of the certificate
x = Request.ClientCertificate("ValidFrom") ' date when the certificate becomes valid
x = Request.ClientCertificate("ValidUntil") ' date when the certificate expires
x = Request.ClientCertificate("SerialNumber") ' certification serial number
x = Request.ClientCertificate("Certificate") ' certificate content in ASN.1 format
x = Request.ClientCertificate("Flags") ' additional client certificate information
%>
<HTML>
<HEAD>
<TITLE>Test ASP</TITLE>
</HEAD>
<BODY>
<form name="MyForm" action="hello.asp" method="post">
<input type="submit" name="MySubmit" value="Submit Form">
<input type="hidden" name="SubmitButton" Value="None">
</form>
</BODY>
</HTML>