Open In App

ASP Application Object

Improve
Improve
Like Article
Like
Save
Share
Report

What is an Application?

An Application is a group of two or more ASP files that use to work together to perform a particular task is called an Application. Similarly, An ASP-based application is defined as the collection of all .asp files in the directory and the sub-directory. The ASP Application Object is a single global object that is used to share information among all the users in the given application. It is used to store and access the variable from any page. It is used to access the information that will hold many pages like a piece of database-connection information. The information that can be changed in one page that will be changed is automatically reflected in many pages. 

Here is the in-built event, methods, and collection of an ASP Application Object:

Collections:

  • Contents: It is used to contain all the items of an application through a script command.
  • StaticObjects: It is used to store all the objects created by using the <object> tag within the scope of the Application object.

Methods:

  • Contents.Remove: It is used to remove items from the Application. Contents Collection.
  • Contents.RemoveAll(): It is used to remove all the items from the Application. contents Collection.
  • Lock: It is used to block other clients from changing the variable which is stored in the Application Object. This method is used to ensure that only one client at a time can change their application variable at a Time
  • Unlock: It is used to give permission to other users for changes to the variable which is stored in the application object after it has been locked.  If the Unlock method is not called explicitly, the server unlocks the locked Application object when the script ends or times out..

Events:

  • Application_OnEnd: This event occurs when the user tries to end or quit the Application.
  • Application_OnStart: It occurs before the beginning of the new session created by the user. It occurs before the Application object is referenced.

Example: Below ASP code demonstrates the use of contents.collection and removes method. 

ASP




<%
Application("'city1")=("Noida")
Application("city2")=("Delhi")
Application("city3")=("Bombay")
Application.Contents.Remove("city2")
for each x in Application.Contents
Response.Write(x & "=" & Application.Contents(x) & "<br>")
next
%>


Output:

city1=Noida
city3=Bombay

Last Updated : 27 Jan, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads