User Guide

216 Chapter 12 Using the Application Framework
Mapping an Application Framework
An important step in designing a ColdFusion application is mapping its directory
structure.
Before you start building the application, establish a root directory for the
application. You can store application pages in subdirectories of the root directory.
Processing Application.cfm and OnRequestEnd.cfm
ColdFusion uses similar but different rules to locate and process Application.cfm
and OnRequestEnd.
Processing Application.cfm
When any ColdFusion application page is requested, ColdFusion searches up the
pages 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 is in the current directory
tree, ColdFusion uses the first one it finds.
Only one Application.cfm file is ever processed for each ColdFusion application
page. The Application.cfm file is automatically included in each application page, as
if by a
cfincludetag. If the Application.cfm page 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.
If an application page has a
cfinclude tag pointing to an additional application
page, ColdFusion does not initiate another search for an Application.cfm page when
it includes the additional page.
If your application runs on a UNIX platform, which is case sensitive, you must spell
Application.cfm with an initial capital letter.
Processing OnRequestEnd.cfm
Just as the Application.cfm file is executed before each application page it governs,
you can specify a file named
OnRequestEnd.cfm, which is executed after each
application page in the same application.
ColdFusion Server looks for the OnRequestEnd.cfm file in the same directory as the
Application.cfm file of the current application page. The
OnRequestEnd.cfm file is
never executed if it resides in another directory.
The OnRequestEnd.cfm file is not executed if there is an error or an exception in the
called page, or if the called page executes the
cfabortor cfexit tag.
Just as the Application.cfm file must be spelled with a capital A on UNIX systems, you
must spell the OnRequestEnd.cfm file with capital O, R, and E.