Creating the Application.cfm File

The special application-wide page called Application.cfm defines application-level settings and functions such as:

Naming the application

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 name attribute in cfapplication is limited to 64 characters.


To name the application:

  1. Open ColdFusion Studio and create a new file.
  2. Modify the file so that it appears as follows:
    <!--- This example illustrates cfapplication --->
    
    
    
    <!--- Name the application --->
    
    <cfapplication NAME="SearchApp">
    
    
  3. Save the file as Application.cfm in the root directory of your application framework.

Setting application default variables and constants

It is often useful to set default variables and application-level constants in the Application.cfm file. For example, you can designate:

Example: Application.cfm

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#">



Banner.Novgorod.Ru