User Guide

Table Of Contents
280 Chapter 13: Designing and Optimizing a ColdFusion Application
How ColdFusion MX finds and process application definition pages
ColdFusion MX uses the following rules to locate and process the Application.cfc,
Application.cfm, and OnRequestEnd.cfm pages that define application-specific elements. The
way ColdFusion MX locates these files helps determine how you structure an application.
Each time ColdFusion MX processes a page request it does the following:
1.
When ColdFusion starts processing the request, it does the following:
It searches the pages directory for a file named Application.cfc. If one exists, it creates a new
instance of the CFC, processes the initial events, and stops searching. (ColdFusion MX
creates a new instance of the CFC and processes its initialization code for each request.)
If the requested page’s directory does not have an Application.cfc file, it checks the directory
for an Application.cfm file. If one exists, ColdFusion MX logically includes the
Application.cfm page at the beginning of the requested page and stops searching further.
If the requested pages directory does not have an Application.cfc or Application.cfm file,
ColdFusion MX searches up the directory tree and checks each directory first for an
Application.cfc file and then, if one is not found, for an Application.cfm page, until it
reaches the root directory (such as C:\). When it finds an Application.cfc or Application.cfm
file, it processes the page and stops searching.
2.
ColdFusion MX processes the requested page’s contents.
3.
When the request ends, ColdFusion MX does the following:
If you have an Application.cfc, ColdFusion MX processes the CFC’s onRequestEnd method
and releases the CFC instance.
If you do not have an Application.cfc, but do have an Application.cfm page,
ColdFusion MX looks for an OnRequestEnd.cfm in the same directory as the
Application.cfm page ColdFusion uses for the current page. ColdFusion does not search
beyond that directory, so it does not run an OnRequestEnd.cfm page that resides in another
directory. Also, the OnRequestEnd.cfm page does not run if there is an error or an
exception on the application page, or if the application page executes the
cfabort or
cfexit tag.
The following rules determine how ColdFusion MX processes application pages and settings:
ColdFusion processes only one Application.cfc or Application.cfm page for each request. If a
ColdFusion page has a
cfinclude tag pointing to an additional ColdFusion page, ColdFusion
MX does not search for an Application.cfc or Application.cfm page when it includes the
additional page.
If a ColdFusion page has a cfapplication tag, it first processes any Application.cfc or
Application.cfm, and then processes the
cfapplication tag. The tag can override the settings
from the application files, including the application name and the behaviors set by the
cfapplication tag attributes.