You are here Articles List / ASP Overview Section 4
Introduction
Response
Request
Application
Session
Server
Application Object
The Application Object is used to store information once that can shared across all the users
of the application simultaneously. An example of this use is database logins, common directories,
and short bits of information that are common to all users.
An example use of the Application Object is to store a web address that is commonly used
throughout the web application. For example, if you were developing an application and several
times in your application you needed to code in the web address to send users back to your
home or main page. When developing this application the address might be one thing, and when
the application is moved from the development to the production environment the main page
web address will likely change. The best way to do this would be to store this bit of
information in an Application variable that is set in one place and called in several. This
way when it needs to be changed, it is changed in one place and not the dozens of places
where you called it.
Here is an example of how to set an Application variable:
Application("myvar") = "http://www.mywebsite.com/dev/index.htm"
In the above code we set an Application variable that can later be called by simply printing
it out where we need it like so:
<A HREF="<%=Application("myvar")%>">Home Page</A>
The = sign is a shortcut to Response.Write and can only be used when you supply the
<% and %> around it. The code above prints our the value of the Application variable
in the a href spot so that when you click on "Home Page" it takes you to wherever the
Application variable specifies.
<< Prev Section - Request Object |
Next Section - Session Object >>
|
|
|
|