Active Server Page (ASP)

ASP - Active Server Page is Microsoft's technology for creating dynamic Web sites. ASP is a scripted page where the script code is run on the web server and plain HTML is sent to be viewed locally on the users browser. This is useful because the programming code is not sent to the browser, so the users cannot view it using the 'view code' option. Also you can return different pages to different users based on their browser types, stored information regarding the users preferences, their 'security' level or other dynamic options you program into your pages. One of the most common uses of ASP is displaying database information. Since this code is first processed on the server and then returned as plain HTML even browsers that aren't Java, Script or ActiveX enabled can see your page since what they are getting is HTML.

Active Server Pages is an extremely flexible technology. You can use Active Server Pages to create anything from a simple homepage to an advanced commercial Web site.

Understanding Objects and Components: Active Server Pages include several built-in objects and installable ActiveX components. An ActiveX component is similar to an Active Server Page built-in object. However, when you are using Active Server Pages, there is one important difference between a component and an object. An instance of a component must be explicitly created before it can be used.
  • The Application object: The Application object is used to store and retrieve information that can be shared among all users of an application. For example, you can use the Application object to pass information between users of your Web site.
  • The Request object: The Request object can be used to access all information sent in a request from a browser to your server. You can use the Request object to retrieve the information that a user has entered into HTML form.
  • The Response object: The Response object is used to send information back to a browser. You can use the Response object to send output from your scripts to a browser.
  • The Server object: The Server object enables you to use various utility functions on the server. For example, you can use the Server object to control the length of time a script executes before it times out. You can also use the Server object to create instances of other objects.
  • The Session object: The Session object can be used to store and retrieve information about particular user sessions. You can use the Session object to store information that persists over the course of a visit by a user to your Web site.
  • The ObjectContext object: The ObjectContext object is used to control Active Server Pages transactions. The transactions are managed by the Microsoft Transaction Server (MTS).
  Application Obj Request Obj Response Obj Server Obj Session Obj ObjectContext Obj
Collections: Contents
StaticObjects
ClientCertificate
Cookies
Form
QueryString
ServerVariables
Cookies Nil Contents
StaticObjects
Nil
Properties: Nil TotalBytes Buffer
CacheControl
Charset
ContentType
Expires
ExpiresAsolute
IsClientConnected
PICS
Status
ScriptTimeout CodePage
LCID
SessionID
Timeout
Nil
Methods: Lock
Unlock
BinaryRead AddHeader
AppendToLog
BinaryWrite
Clear
End
Flush
Redirect
Write
CreateObject
HTMLEncode
MapPath
URLEncode
Abandon SetAbort
SetComplete
Events: Application_OnEnd
Application_OnStart
Nil Nil Nil Session_OnEnd
Session_OnStart
OnTransactionAbort
OnTransactionCommit

Note: The methods(to do some type of procedure), collections(bits of information that are accessed in the same way) and properties(to store any of the object's attributes) of a built-in objects are automatically accessible throughout a Web-site application.

  • Database Access component: The Database Access component uses ActiveX Data Objects (ADO) to access information stored in a database or other tabular data structure.
  • Ad Rotator Component: The Ad Rotator component creates an Ad Rotator object that automates the rotation of advertisement images on a Web page. Each time a user opens or reloads the Web page, the Ad Rotator component displays a new advertisement based on the information you specify in a Rotator Schedule File.
  • Page Counter Component: The Page Counter component creates a PageCounter object that counts and displays the number of times a Web page has been opened. At regular intervals the object writes the number of hits to a text file so that in the event of a server shutdown, the data is not lost. The Page Counter component uses an internal Central Management object to record how many times each page in the application has been opened.
  • File Access Component: The File Access component exposes methods and properties you can use to access a computer's file system. You can use the File Access Component to create a FileSystemObject object which provides the methods properties and collections you use to access the file system.
Using the Global.asa File

The Global.asa file is an optional file in which you can specify event scripts and declare objects that have session or application scope. It is not a content file displayed to the users; instead it stores event information and objects used globally by the application. This file must be named Global.asa and must be stored in the root directory of the application. An application can only have one Global.asa file.

< SCRIPT LANGUAGE="VBScript" RUNAT="Server" >
SUB Session_OnStart
This event occurs whenever a new visitor requests the first page contained within the Active Server Pages application.
END SUB
SUB Session_OnEnd
This event occurs when a user session ends. By default, a user session ends after a page has not been requested by the user for more than 20 minutes.
END SUB
SUB Application_OnStart
This event occurs when the first page from an Active Server Page application is requested by any user. Typically, the Application_OnStart event is triggered after your Web server is restarted or after the Global.asa file is modified.
END SUB
SUB Application_OnEnd
This event is triggered when your Web server shuts down. It's the last event called after all of the Session_OnEnd events are triggered.
END SUB
< /SCRIPT >
 
Copyright © 2002 by EzSofTech. All Rights Reserved.