ASP Notes

  1. ASP Quick Reference
  2. ASP Examples
  3. Introduction
    Active Server Pages
    ASP is a program that runs inside Internet Information Services,(IIS).
    IIS comes with Windows 2000 and is a part of the Windows NT 4 option pack which can be downloaded from Microsoft.
    Personal Web Server,(PWS), is a smaller, fully functional version of IIS for Windows 95 and Windows 98.
  4. Running ASP locally
    You must install PWS or IIS.
  5. ASP Syntax
    You cannot view the ASP source code by selecting "view source" in a browser, you will only see the output from the ASP file which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.
  6. ASP Variables
    Global variables are declared outside the procedures.
    Local variables are declared inside a procedure.
  7. ASP Procedures
  8. ASP Forms
    Use the Request.QueryString and the Request.Form commands to retrieve information from forms... like user input.
  9. ASP Cookies
    Cookies are often used to identify users
    Example: The Welcome Cookie.
                <%
                  dim numvisits
                  response.cookies("NumVisits").Expires=date+365
                  numvisits=request.cookies("NumVisits")
                %>
                <html>
                  <body>
                    <%
                      if numvisits="" then response.cookies("NumVisits")=1
                    %>
                      Welcome! This is the first time you are visiting this Web page.
                    <%
                      else
                         response.cookies("NumVisits")=numvisits+1
                         response.write("You have visited this ")
                         response.write("Web page " & numvisits)
                         if numvisits=1 then
                           response.write " time before!"
                         else
                           response.write " times before!"
                         end if
                      end if
                    %>
                  </body>
                </html>
              
    A cookie is a small file that the server writes to the user's computer. Each time the same computer requests for a page with a browser, it will send the cookie too. With ASP you can create and retrieve cookie values.
  10. ASP Session Object
    When you are working with an application, you open it, do some changes and then close it. This is musck like a session. The computer knows who you are. It knows when you start the application and when you end. But on the internet the server doesn't know who you are or what you are doing because the HTTP address doesn't maintain state.
    ASP therefore creates a unizue cookie foe earch user. The cookie is sent to the client and it contains information that identifies the user. This interface is called the Session Object.
    The session object is used to store information about, or change settings for a user session. Variables stored in the session object hold information about one single user and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new session ojbect for each new user and destroys the session object when the session expires.
    A Session Starts When:
    * A user requests an ASP file and the Global.asa file includes a
      Session_OnStart procedure.
    * A value is stored in a Session variable.
    * A user requests an ASP file and the Global.asa file uses the <object> tag
      to instantiate an object with session scope.
    A Session Ends When:
    A user has not requested or refreshed a page in the application for a specified period of time. By default, this is 20 minutes.
    If you want to set a timeout interval that is shorter or longer than the default you can seet the Timeout property.
    Example:
                    <%
                      Session.Timeout=5
                    %>
                  
    To end a session immediately, you can use the Abandon method:
                    <%
                      Session.Abandon
                    %>
                  
    The main problem with sessions is WHEN they should end.
    We do not know if the user's last request was the final one or not so we do not know how long we should keep the session alive.
    Waiting too long uses up resources on the server, but if the session is deleted too soon you risk the user returning after the server has deleted all the information.
    IF you are using session variables, store small amounts of data in them.
  11. ASP Application Object
    An application on the web may be a group of ASP files. The ASP files work together to perform some function. The application object in ASP is used to tie these files together.
    The Application object is used to store and access variables from any page just like the Session object. But All users share one Application object while Each user has their own Session object.
    The Application object should hold information that will be used by many pages in the application, like databse connection information. This means that you can access the information from any page. It also means that you can change the information in one place and the changes will automatically be reflected on all pages.
  12. ASP #include
    The #include directive is used to create functions, headers, foorters or elements that will be reused on multiple pages.
  13. ASP Global.asa
    The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application. All valid browser scripts can be used within Global.asa.
    The Global.asa file can only contain the following.
    * Application events.
    * Session events.
    * <object> declarations.
    * TypeLibrary declarations.
    * the #include directive.
    Note the Global.asa file must be stored in the root directory of the ASP application and each application can have only 1 Global.asa file.
  14. ASP Response Object
    The ASP Response object is used to send output to the user from the server.
  15. ASP Request Object
    The ASP request object is used to get information from the user.
  16. ASP Application Object
    An applciation on the web may be a group of ASP files. The ASP files work together to perform some purpose. The application object in ASP is used to tie these files together.
    The application object is used to store and access variables from any page just like the session object. But ALL users share one application object and there is only one session object for EACH user.
    The application object should hold information that will be used by many pages in the application; like database connection information. This means that you can access the information from any page. It also means that you can change the information in one place and the changes will automatically be reflected on all pages.
  17. ASP Session Object
    The session object is used to store information about, or change settings for a user session. Variables stored in the session object hold information about one single user and are available to all pages in one application.
    ASP creates a unique cookie for each user. The cookie is sent to the client and it contains information that identifies teh user. This interface is called the session object.
    Common information stored in the session variables are name, id and preferences. The server creates a new session object for each new user and destroys the session object when the session expires.
  18. ASP Server Object
    The ASP Server object is used to access properties and methods on the server.
  19. ASPError Object (ASP 3.0)
    The ASPError object is implemented in ASP 3.0 and it is only available in IISS.
    The ASP Error object is used to display detailed information of any error that occurs in scripts in the ASP page. The ASPError object is created when Server.GetLastError is called, so the error information can only be accessed by using the Server.GetLastError method.
  20. ASP FileSystem Object
      The FileSystemObject is used to access the file system on the server. This object can manipulate files, folders and directory paths, and retrieve file system information.
  21. ASP TextStream Object
    The TextSream object is used to access the contents of text files.
  22. ASP Drive Object
    The Drive object is used to return information about a local or network drive.
    Use the Folder object to return information about the CONTENTS of a drive.
  23. ASP File Object
    The ASP File object is used to return information about a specified file
  24. ASP Folder Object
    The ASP Folder object is used to returns information about a specified folder.
  25. ASP Dictionary Object
    The Dictionary object is used to store information in name/value pairs, refferred to as key and item... similar to arrays, but are non-multidimensional, have more built in functions, and access the data better than array's.
  26. ASP AdRotator Component
    The ASP AdRotator component creates an AdRotator object that displays a different image each time a user enters or refreshes a page. A text file includes information about the images.
  27. ASP Browser Capabilties Component
    The ASP browser capabilities component creates a browser type object that determines the type, capabilities and version number of each browser that visits the site.
    When a browser connects to a server, an HTTP user agent header is also sent to the server. This heder contains information about the browser. The BrowserType object compares the information in the header with information in a file on the server called "Browscap.ini".
    If there is a match between the browser type and the version number sent in the header and the information in the "Browsercap.ini" file, you can use the BrowserType object to list the properties of the matching browser. If there is no match for the browser type and version number it will set every property to "UNKNOWN".
  28. ASP Content Linking Component
    The ASP Content Linking component is used to create a quick and easy navigation system by returning a Nextlink object that is used to hold a list of web pages to be navigated.
  29. ASP Content Rotator Component
      The Content Rotator Component creates a ContentRotator object that displays a different HTML content string each time a user visits or refreshes a page. A text file called the Content Schedule File contains the information about the content strings. The content strings can contain HTML tags so you can display any type of content that HTML can represent: text, images, colors and links.
Hosted by www.Geocities.ws

1