The special application-wide page called Application.cfm defines application-level settings and functions such as:
In ColdFusion, you define an application by giving it a name using the cfapplication
tag. By using the same application name in a cfapplication
tag, you define a set of pages as part of the same logical application.
Note The value you set for the |
<!--- This example illustratescfapplication
---> <!--- Name the application ---> <cfapplication
NAME="SearchApp">
It is often useful to set default variables and application-level constants in the Application.cfm file. For example, you can designate:
The following example shows a complete Application.cfm file for the sample Products application:
<!--- Set application name and enable Client variables, stored in a data source called mycompany --->
<cfapplication name="Products" clientmanagement="Yes" clientstorage="mycompany" sessionmanagement="Yes"> <!--- Set custom global error handling pages for this application---> <cferror type="REQUEST" template="requesterr.cfm" mailto="admin@company.com"> <cferror type="VALIDATION" template="validationerr.cfm"> <!--- Set application-specific constants. These are put in the Variables scope of every page in the application---> <cfset homepage="http://www.mycompany.com"> <cfset primarydatasource="CompanyDB"> <!--- set global error handling for this application ---> <!--- set Session variable for this application.---> <!--- Note that the cfset tag is surrounded by a cflock tag ---> <cflock timeout="30" scope="Session" type="exclusive"> <cfset session.current_location = "Davis, Porter, Alewife"> </cflock> <cfset mainpage = "default.cfm"> <cfset sm_location = "dpa"> <cfset current_page = "#cgi.path_info#?#cgi.query_string#">