KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones

Application

In ASP, an application can be thought of as a virtual directory on the IIS web server. It includes all of the pages(static and dynamic) in the directory tree. It is the Application object's responsibility of providing a means to control the application from a single point.

When IIS is installed in Windows, a default web site is located at c:\InetPub\WWWRoot by default. This is the directory ASP default asp application reside in. We could create our own ASP virtual application in any sub-directory of the Web site. This application also contains all the sub-directories of the directory defined as "application directory". Note that, this directory and its sub-directories are also part of the default application, and they share the global space created by the default Application object. This means that all the variables stored in the default application are also available within the application in a sub-directory. However, if an ASP page in the sub-directory application writes a value in its Application object that has the same name as an existing one in the default(root) application, the original value is no longer available within the sub-directory application. But, in other applications or ASP pages, the original value is maintained, because the root application can not see the variables in the sub-directory application.

The Application Object

The application object is a program/data structure that enables you to manage an entire application.
Applications correspond to the virtual directories on the web server and the collection of pages and objects included in those directories. The Application objects are the ASP objects which control access to the application. Each Session is an individual client session (connection) with the application.

Application Variables

Application variables can be seen by all the clients accessing the application, and are known as application-scope variables.

global.asa
The global.asa file is used to initialize application wide variables and otherwise tailor the environment for the application. There can only be one global.asa file per application. It is placed in the root directory of the application, and applies to all sub-directories of that directory.

Collections

The application object has two collections:

Contents: Contains all of the items that have been added to the Application through script commands

StaticObjects Contains all of the objects added to the session with the tag.

Methods

The application objects contains two methods:

Lock The lock method prevents other clients from modifying Application object properties.

Unlock: The unlock method allows other clients to modify Application object properties.

Events

The application object supports two Events:

Application_OnEnd Triggered when an application ends(server stopped)
Application_OnStart Triggered when a application starts (first visitor to the applications calls the first .asp page)

Scripts for the preceding events are declared in the global.asa file.

<script language=vbscript runat=server>
sub Application_onStart
Application.lock
Application("myAppVariable")=now
Application("anotherAppVariable")=CStr(Cint(Application("anotherAppVariable"))+1)
Application.Unlock
end sub
</script>

Each of these variables would be members of the Application Contents Collection.

You can also assign a component instance to a variable that has application scope. If you assign a component instance to a variable with the Server.CreateObject method, the variable will be a member of the Application.Contents collection. If the variable is assigned with the tag<object>, the variable will be a member of the Application StaticObjects Collection.

You should be careful about assigning component instances to variables with application scope, as some components are not designed to be given application scope.

If you assign a component instance to a variable in the Application Contents Collection, and use Visual Basic. scripting Edition as your primary scripting language, you must use the Set keyword. This is illustrated in the following script:

<% set Application("Obj1") = Server.CreateObject("MyComponent")%>

You can then reference the methods and properties of MyComponent on subsequent Web pages by using this script


<% Application("Obj1").MyObjMethod %>

or by extracting a local copy of the object and using the following

<%
set MyLocalObj1 = Application("obj1")
MyLocalObje1.MyObjMethod
%>

Another way to create objects with application scope is by using the tag in the global.asa file like following script:

<!-- Declare instance of ASPContenetLink object with Application-level scope>
<OBJECT id="ASPContentLink" Runat="Server" SCOPE="Application" PROGID="MSWC.NextLink">
</OBJECT>

You cannot store a built-in object in the Application object. For example, each of the following lines returns an error:


<%
Set Application("var1")=Session
Set Application("var2")=Request
Set Application("var3")=Response
Set Application("var4")=Server
Set Application("var5")=Application
Set Application("var6")=ObjectContext
%>

ASP tutorial
What is ASP
Install IIS
VBScript or JScript
ClientSide vs ServerSide scripting
ASP execution order
Dealing with Form
More Form example
Variable &Variant
String
Local variable
Global variable
Arrays
Use if_then_else
Use Select Case
For_Next loop
Do_while loop
Subroutine vs Function
Request Object
QueryString
Count Keyword
Using QueryString
Application, Method, Events
Create Virtual Directory
Save array in Application
Session, Method, Events
Using Cookie
Server Object
Ad Rotator
Content Linker
Browser
Dictionary object
Filesystemobject Object

 

 

 

 

Best books about ASP & ASP.Net from Amazon
Beginning Dynamic Websites : with ASP.NET Web Matrix (Programmer to Programmer) (Paperback) Build Your Own ASP.NET Website Using C# & VB.NET (Build Your Own) (Paperback) Professional Active Server Pages 3.0 (Programmer to Programmer) (Paperback) ASP.NET Cookbook (Paperback) ASP.NET Kick Start (Paperback)

 

Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © kidslovepc.com All rights reserved(new). Privacy|Copyright
designed by info@kidslovepc.com

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer