Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

asp

What is Application in ASP?

Adnan Abbas

The Application object is used to tie together the different files used in an ASP application. Similar to the Session object, the Application object is used to store and access variables. However, the Application object is common for all users, while the Session object is unique for each user.

The Application object holds information such as the database server connection useful for many pages in the application. Any page can access this information, and if changed, it is reflected on all pages.

Creating Application variables

Application variables are created in the “Global.asa” file in the following manner:

<script language="vbscript" runat="server">

Sub Application_OnStart
application("load")=""
application("totalUsers")= 400
End Sub

</script>

Accessing Application variables

This is how we can access the Application variables load and totalUsers that we created in the example above:

<%
Application("totalUsers")
Application("load")
%>

To access all the variables stored in the Application object, we can use the .Contents method and loop through it:

<%
dim i
For Each i in Application.Contents
  //execution
Next

>

Lock and unlock

We can ensure atomicity while modifying the application object by using the .Lock method. When an application is locked, it cannot be modified by other users. To unlock the application, we can use the .Unlock method:

<%
Application.Lock
'perform operations on the application variables'
Application.Unlock
%>

RELATED TAGS

asp

CONTRIBUTOR

Adnan Abbas
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring