![]() ![]() ![]() |
When any ColdFusion application page is requested, ColdFusion searches up the page's directory tree for an Application.cfm
file. When it is found, the Application.cfm
code is logically included at the beginning of that page.
If it is not found, ColdFusion searches up the directory tree until it finds an Application.cfm
file. If more than one Application.cfm
file lives in the current directory tree, ColdFusion uses the first one it finds.
ColdFusion continues searching for the Application.cfm
file up to the root directory of the hard drive where the web root resides.
Because the Application.cfm
page is processed before any other application page, it gives you the ability to set application-level parameters, and to perform queries and other functions.
Since Application.cfm
files are standard ColdFusion application pages, you may use CFML code within them to dynamically determine the values of application-level settings based on queries, client-state information, and so on.
By defining a scope for one or more applications, Application.cfm
files can be implemented for individual or multiple applications. A single Application.cfm
file, installed in your ColdFusion application root directory, can globally control settings in multiple applications nested below the root.
ColdFusion Server scope variables are available to all application pages. This is a potential source of conflict with variables set in Application.cfm
pages. See How ColdFusion looks up variables in Chapter 4, Creating and Manipulating Variables for information on the order in which ColdFusion finds variables.
The flexibility of ColdFusion allows for a number of different ways to configure ColdFusion applications. The following sections describe a basic approach that will work for most cases.
An important step in designing a ColdFusion application is mapping out its directory structure.
Before you start building the application, establish a root directory for the application. Application pages may also be stored in sub-directories of the root directory.
In UNIX, the references to Application.cfm
are case-sensitive. The filename must be spelled with an initial capital.
Application.cfm
file in the root of the application directory for application-level settings.
For details on setting up user security in the Application.cfm
file, see the user security information in Advanced ColdFusion Development.
All of the page files in an application do not need to be in the same root directory. However, defining a root directory for an application has a number of advantages:
You can use a single Application.cfm
file for your application, or use many different Application.cfm
files that govern individual sections of the application.
The directory trees below illustrate two approaches to implementing the Application Framework.
Application.cfm
file installed in their application root directory to process all application page requests.
Application.cfm
files to specify processing for ColdFusion applications at the departmental level. Only the Products application pages are processed using the settings in the root Application.cfm
file. The Consulting, Marketing, and Sales directories each has its own Application.cfm
file.
Only one Application.cfm
file is ever processed for each ColdFusion application page. The presence of an Application.cfm
file is an implicit CFINCLUDE. If it is present in the directory tree, there is no way not to include it. (For this reason, it is the ideal location to set application-level variables.)
When the requested application page has a CFINCLUDE tag pointing to an additional application page, ColdFusion does not initiate another search up the directory tree based on the included application page.
This is an important behavior to understand. Upon opening a requested application page, ColdFusion searches for the Application.cfm
file only once.
![]() ![]() ![]() |
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.