![]() ![]() ![]() |
||
|
When you design a ColdFusion application, you must structure its contents into directories and files, also known as mapping the directory structure. This activity is an important step in designing a ColdFusion application. Before you start building the application, you must establish a root directory for the application. You can store application pages in subdirectories of the root directory.
The following sections describe how ColdFusion uses application-specific pages and how you can organize your application pages in a directory structure.
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:
onRequestEnd
method and releases the CFC instance.cfabort
or cfexit
tag.The following rules determine how ColdFusion MX processes application pages and settings:
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. 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.cfapplication
tags that use the same application name. In this case, all pages that have the same name share the same application settings and Application scope and can set and get all the variables in this scope. ColdFusion uses the parameter settings of the cfapplication
tag or the most recently processed file, if the settings, such as the session time-out, differ among the files.Note: If your application runs on a UNIX platform, which is case-sensitive, you must spell Application.cfc, Application.cfm, and OnRequestEnd.cfm with capital letters, as shown.
Defining an application directory structure with an application-specific root directory has the following advantages:
Development The application is easier to develop and maintain, because the application page files are well-organized.
Portability You can easily move the application to another server or another part of a server without changing any code in the application page files.
Application-level settings Application pages that are under the same directory can share application-level settings and functions.
Security Application pages that are under the same directory can share web server security settings.
When you put your application in an application-specific directory hierarchy, you can use a single application definition (Application.cfc or Application.cfm) page in the application root directory, or put different application definition pages that govern individual sections of the application in different directories.
You can divide your logical web application into multiple ColdFusion applications by using multiple application definition pages with different application names. Alternatively, you can use multiple application definition pages that specify the same application name, but have different code, for different subsections of your application.
The directory trees in the following figure show two approaches to implementing an application framework:
|
||
![]() ![]() ![]() |