home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Documentation / snippets / cfapplication1.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  3.0 KB  |  75 lines

  1. <!--- This is a view-only example to illustrate CFAPPLICATION --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>CFAPPLICATION Example</TITLE>
  5. </HEAD>
  6.  
  7. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  8. <BODY  bgcolor="#FFFFD5">
  9.  
  10. <H3>CFAPPLICATION Example</H3>
  11.  
  12. <P>CFAPPLICATION defines scoping for a Cold Fusion application
  13. and enables or disables the storing of client and/or session
  14. variables.  This tag is placed in a special file called
  15. Application.cfm that is run before any other CF template in
  16. a directory where the Application.cfm file appears. You can not 
  17. browse a file named Application.cfm since it is only supposed
  18. to accessed by other files that use variables defined within it.
  19. <P>Here is a read-only listing of a typical Application.cfm file:
  20.  
  21. <!-- Begin Application -->
  22. <!-----------------------------------------------------------
  23.     MODULE:            Application.cfm
  24.     PURPOSE:        Application.cfm file for our sample
  25.     CREATED:         today's date
  26.     AUTHOR:            the author
  27.     COPYRIGHT:        (c) 1999 the author for a company
  28.     CHANGE HISTORY: 
  29. ----------------------------------------------------------->
  30. <!-----------------------------------------------------------
  31. Name the application "eturtle" and turn on Session Management.
  32. ----------------------------------------------------------->
  33. <!-----------------------------------------------------------
  34. <CFAPPLICATION name="eturtle" sessiontimeout="60" sessionmanagement="yes">
  35. <!--- set datasource for this application --->
  36. <CFSET dsn = "my_dsn">
  37. <!--- set global error handling for this application --->
  38. <CFERROR TYPE="REQUEST" TEMPLATE="request_err.cfm" MAILTO="webmaster@mysite.com">
  39. <CFERROR TYPE="VALIDATION" TEMPLATE="val_err.cfm" MAILTO="webmaster@mysite.com">  
  40.  
  41. <!-----------------------------------------------------------
  42. Set some global variables for this application to
  43. be triggered on every template. The following lock names
  44. the session with the sessionID variable. Note that you should 
  45. always lock session and application variables when you initialize 
  46. and update them. 
  47. ----------------------------------------------------------->
  48. <CFLOCK Name="#session.sessionID#" timeout="30">
  49.     <CFIF NOT IsDefined("session.current_location")>
  50.         <CFSET session.current_location = 'Davis, Porter, Alewife'>
  51.     </CFIF>    
  52. </CFLOCK>
  53.  
  54. <!-----------------------------------------------------------
  55. Set application variables. Always lock shared variables prior
  56. to writing to them. Use the applicationName variable
  57. to specify the lock name.
  58. ----------------------------------------------------------->
  59.  
  60. <CFLOCK Name="#application.applicationName#" timeout="30">
  61.     <CFIF NOT IsDefined("application.MainPage")>
  62.         <CFSET application.MainPage = "default.cfm">
  63.     </CFIF>
  64.     <CFIF NOT IsDefined("application.sm_location")>
  65.         <CFSET application.sm_location = "dpa">
  66.     </CFIF>
  67.     <CFIF NOT IsDefined("application.current_page")>
  68.         <CFSET application.current_page = "#cgi.path_info#?#cgi.query_string#">
  69.     </CFIF>    
  70. </CFLOCK>
  71. ----------------------------------------------------------->
  72. <!-- End Application -->
  73. </BODY>
  74. </HTML>       
  75.