O'Reilly logo

Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started by Charlie Arehart, Raymond Camden, Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Initializing Application Variables

Application variables are persistent. That simply means that once you create them, they stick around. Because of this, there is no reason to set them on every request. Once you create an Application variable, you don’t need to create it. Once simple way to handle that would be with the isDefined() function.

<cfif not isDefined("APPLICATION.dsn")>
  <cfset APPLICATION.dsn = "ows">
</cfif>

This code will check to see if the variable, APPLICATION.dsn exists. If it doesn’t, it will create it. However, the Application.cfc component provides an even easier way to do this. One of the special methods mention in Table 19.1 is the onApplicationStart() method. This method will execute only when the application starts. Conversely, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required