home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Listing 33.4 Using the ASP Objects


<%@ LANGUAGE=”VBSCRIPT” %>
<% Session(“User_ID”)   = Request.Form(“User_Id”) %>
<% Session(“nba_Online”)= Request.Form(“nba_online”) %>
<% Session(“nfl_Online”)= Request.Form(“nfl_online”) %>
<%
If IsEmpty(Session(“User_Id”)) Then
        Response.Redirect “invalid.htm”
Else
        If Request.Form(“report_type”)=“nba” Then
                If Session(“nba_Online”)=“Y” Then
                       Response.Redirect “latest_nba.htm”
                Else
                       Response.Redirect “invalid.htm”
                End If
        Else
                If Session(“nfl_Online”)=“Y” Then
                      Response.Redirect “latest_nfl.htm”
                Else
                      Response.Redirect “invalid.htm”
                End If
        End If
End If
%>

Note that no HTML is in this file. That’s because all output sent to the browser is handled through the redirects, not by dynamically writing out any HTML.

Active Server Page Objects

Five fundamental server objects typically form the core of ASP applications:

  Application—The Application object manages your Web application’s information.
  Session—The Session object manages and tracks individual user sessions within your Web application.
  Server—The Server object controls behavior of your Web server.
  Response—The Response object transmits information from the Web server to the browser.
  Request—The Request object retrieves information from the browser for processing at the server.

Like any other object within an object-oriented programming world, the five ASP objects have specific events, methods, and properties. You can use an ASP object’s events, methods, and properties to configure the object per your application and business requirements. You will learn more about the methods and properties of ASP objects in the following sections. These five ASP objects are extremely critical for developing an ASP application.

The Application Object

By using the Application object, you can manage your Web application’s information. You can pass application-level information between different users of the application. In addition, you can lock and unlock an application-level variable. When you lock an application-level variable, users of the application cannot modify the variable’s value. After you release the lock, users can modify the variable’s value.

Events The Application object supports the following two events:

  Application_OnStart—Triggered when the application starts
  Application_OnEnd—Triggered when the application terminates

You will find the Application object’s two events within your application’s global.asa file.


NOTE:  The global.asa file is an Active Server application file you can use to track and manage the application and session events, variables, and objects. When you start the application, the server will load the global.asa file into memory.

Variables You declare application-level variables within your application’s global.asa file. The following line of code, for example, declares an application-level variable myAppTitle. After you declare the variable, all users of the application will have access to the variable

Application(“myAppTitle”)=“My First ASP application”

In the next section, you will learn how you can use the Application object’s Lock and UnLock methods with your application-level variables.

Methods Two primary types of methods are used in the Application object:

  Lock—By using the Lock method, you can prevent another user from updating or changing the application-level variable’s value.
  UnLock—By using the UnLock method, you can release the control on the application-level variable. The following code demonstrates the use of Lock and UnLock methods:
<%
Application.Lock
Application(““errMsg””)=““Please contact the Plan Administrator””
Application.UnLock
%>

The Session Object

By using the Session object, you can manage information about a specific user of your Web application. The user information is specific only to the user, and one user cannot access or modify another user’s information. The Session object includes the events, properties, and methods described in the following sections.


NOTE:  The Session object is extremely useful because HTTP does not allow for tracking of state information.

Events

Like the Application object, the Session object also supports the following two events:

  Session_OnStart—Triggered when the server starts a new user session
  Session_OnEnd—Triggered when the server terminates the user session

You will find the Session object’s two events within your application’s global.asa file.


NOTE:  By using the Abandon method that falls under the Session object, you can explicitly close a user’s session rather than waiting for the user to close it. As a result, the server will automatically release all resources consumed by the user session and destroy the user Session object. The syntax for the Abandon method is
Session.Abandon

where Session is the current Session object.




Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.