Docstoc

asp

Document Sample
asp Powered By Docstoc
					MS Active Server Pages


        CS-422
      Dick Steflik
Microsoft Active Server Pages
• Core technologies
   –   MS Internet Information Server
   –   MS Internet Explorer (IE4.0)
   –   VBScript
   –   Java
   –   ActiveX
   –   SQL Server & Access
   –   COM, DCOM
Microsoft ASP Architecture
Windows NT/W2000

                    HTML
      IIS          JavaScript
                   VBScript
   VBScript          Java
                    ActiveX

  Data Base,         IE 4.0
   (ODBC,
   Access,
  SQLServer)
                   Windows DNA
• Windows Distributed interNet Architecture
   – Microsoft’s initiative for distributed computing over the Internet
   – 3-tier computing with a Microsoft flavor
   – DNA guidelines require all distributed clients to support both
     Windows and non-Windows clients along with both Windows and
     non-Windows datasources
• ASP and Distributed Computing
   – using distributed computing you should be able to plug in
     anywhere to get the information you need, when you need it
   – The ASP architecture is central to Microsoft’s fulfilling this
     promise
How ASP works
• ASP.DLL - this is an ISAPI filter that is invoked in response to IIS
  receiving a request for a file of type .asp, it alters the HTTP response
  stream in accordance with information in the HTTP request combined
  with codes found in the document.
• The document is parsed looking for VBScript delimiters; <% … %>
  or <%=…%>
• undelimited information (text and HTML) is passed back to the
  requesting client, as is.
• delimited text is processed by the VBScript processor, and either
  resolved to text and returned to the client or maintained in the
  VBScript environment as variable or program state data.
• The delimitor form <%=…%> is a short cut for using the Write
  method of the Response object to write programatic information
  directly back to the client
VBScript
• a subset of the Visual Basic programming language
    – doesn’t include VBs visual components
• a set of predefined objects
    –   Application object
    –   ASPError object
    –   ObjectContext object
    –   Request object
    –   Response object
    –   Server object
    –   Session object
Application object
• An ASP application is made up of all of the files that can be accessed
  through an application virtual directory and its subdirectories, this is
  called an ASP application context and it’s the same for all clients
• the Application object allows you to share information among all
  clients currently using the application.
• The Application object is created as soon as the first client access the
  application and exists until: the web service is stopped or the
  application us unloaded via the admin console.
• Allows instantiation of variables and objects with application level
  scope. This can also be done via the GLOBAL.ASA file
• These are essentially global variables , accessible to all colients of the
  application
Applications object -
             Contents Collection
• Contains all application-level scope variables and objects
• has three properties:
    – item; set or retrieve the value of a specific member (specified by a key or
      index position)
         • to set - Application.Contents.Item(“PI”) = 3.14
         • to get - xyz = Application.Contents.Item(“PI”)
    – key; name of a specific element
    – count; total # of elements in the collection
• methods:
    –   Remove;
    –   RemoveAll
    –   StaticObjects
    –   Lock
    –   Unlock
• Events: OnEnd ; On Start
ASPError object
• Allows detailed viewing of the last error that occurred
• Object is read-only; to use you must call GetLastError method of
  Server object
    – ex.     Dim objMyASPError
    –        set objMyASPError = Server.GetLastError
• Properties:
    –   ASPCode-numeric code for the ASP error
    –   ASPDescription-more descriptive than ASPCode
    –   Category - type of error (textual)
    –   Column-character column of the error
    –   Description - better desc than the ASPDescription
    –   File - full path to file containg error
    –   Line - line number of error
    –   Number - error code
    –   Source- line of source code causing the error
• Methods: none
• Events: none
ObjectContext object
• Used with database trancaction for making transactional scripts
• allows creation of units of code that either fail or pass; no partial
  successes allowed; real useful in database applications
• Properties: none
• Collections: none
• Methods:
    – SetAbort
    – SetComplete
• Events:
    – OnTransactionAbort
    – OnTransactionCommit
Request object
• Gives access to information in the HTTP request header
• Properties:
    – TotalBytes - read-only, total number of bytes sent in the request header
• Collections:
    – ClientCertificate - information about any digital certificates
    – Cookies - cookie info from the client
         • http://www.netscape.com/std/cookie_spec.html
         • http://www.cookiecentral.com/unofficial_cookie_faq.html
    – Form - retrieve info posted via a POST : ex. Request.Form.Item(“name”)
    – QueryString - allow retrieval of info posted via a GET
    – ServerVariables - pre-defined server environment info (next slide)
• Methods:
    – BinaryRead
• Events: none
ServerVariables
• Most other header information and server info
ALL_HTTP              HTTP_ACCEPT                 PATH_TRANSLATED
ALL_RAW               HTTP_AUTHORIZATION          QUERY_STRING
APPL_MD_PATH          HTTP_ACCEPT-LANGUAGE        REMOTE_ADDR
APPL_PHYSICAL_PATH    HTTP_CONNECTION             REMOTE_HOST
AUTH_PASSWORD         HTTP_HOST                   REQUEST_METHOD
AUTH_TYPE             HTTP_REFERER                SCRIPT_NAME
AUTH_USER             HTTP_USER_AGENT             SERVER_NAME
CERT_COOKIE           HTTPS_KEYSIZE               SERVER_PORT
CERT_FLAGS            HTTPS_SECRETKEYSIZE         SERVER_PORT_SECURE
CERT_ISSUER           HTTPS_SERVER_ISSUER         SERVER_PROTOCOL
CERT_KEYSIZE          HTTPS_SERVER_SUBJECT        SERVER_SOFTWARE
CERT_SECRETKEYSIZE    INSTANCE_ID                 URL
CERT_SERIALNUMBER     INSTANCE_META_PATH
CERT_SERVER_SUBJECT   LOCAL_ADDR
CERT_SUBJECT          LOGON_USER
CONTENT_TYPE          PATH_INFO
CONTENT_LENGTH
Response object
• Provides control over what goes into the HTTP response header
• Properties;
    –   Buffer
    –   CacheControl
    –   Charset
    –   Expires
    –   ExpiresAbsolute
    –   IsClientConnected
    –   PICS
    –   Status
• Collections: Cookies
• Methods:
    –   AddHeader
    –   AppendToLog
    –   BinaryWrite
    –   Clear
    –   Flush
    –   Redirect
    –   Write
Server object
• Miscellaneous functions
• Properties:
    – ScriptTimeout - to limit long running scripts - default 90 sec
• Collections: none
• Methods:
    –   CreateObject - Creates an object on the server (seperately installed objs)
    –   Execute - call and execute one ASP script from inside another
    –   GetLastError - get the Last Error Object
    –   HTMLEncode - used to display the actual HTML code
    –   MapPath - given the virtual or relative path get the actual path on server
    –   Transfer - redirect execution from onescript to another
    –   URLEncode - URL encodes a string
• Events: none
Session object
• Allows recording and management of a user session
• Properties:
    –   CodePage - integer representation of CodePage to be used to display
    –   LCID - int to specify special formating based on locale
    –   SessionID-unique ID that identifies the session
    –   Timeout- minutes that webserver will maintain the session
• Collections:
    – Contents - all variables and objects with session-level scope
    – StaticObjects - all vars and objects added via <OBJECT> tag
• Methods:
    – Abandon - release memory assoc with a specific session
    – ContentsRemove -
    – ContentsRemoveAll
• Events:
    – Session_OnEnd
    – session_OnStart

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:29
posted:8/17/2011
language:English
pages:16