[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

Coldfusion Naming Conventions

I've inherited a bunch of coldfusion sites.

On some of them - in the root directory - there's an...

"application.cfc"
and an...
"Application.cfc"

I'm kind of a novice to ColdFusion.

Can someone explain to me the hierarchy of how "APPLICATION" is handled - i.e., is it the lower case that defaults, or the upper case?  Do you normally on linux based servers keep two of the same filename - one as a backup?  How do I know which one to mess with - without potentially screwing something up?

Thanks!
0
erzoolander
Asked:
erzoolander
  • 3
  • 3
  • 2
  • +2
1 Solution
 
_agx_Commented:
I do not use linux, but I've always read that the one with uppercase "A" is the only one used on linux.  

http://livedocs.adobe.com/coldfusion/8/AppEvents_01.html
Note: Although Windows is case-insensitive, you should always start the Application.cfc filename with an uppercase A.
0
 
_agx_Commented:
Finally found the reference.  It is case sensitive. From the docs

"...Note: UNIX systems are case-sensitive. To ensure that your pages work on UNIX, always capitalize the A in Application.cfm [ie and Application.cfc] and the O, R, and E in OnRequestEnd.cfm.

How do I know which one to mess with - without potentially screwing something up?

You could easily verify it.  Create an isolated test folder and two application files containing some simple debugging code.

Application.cfc
<cfcomponent output="false">
      <cfset this.name = "UpperCaseA">
      <cfset this.sessionManagement = true>
      <cfset this.sessionTimeOut = createTimeSpan(0,0,0,15)>

      <cffunction name="onRequestStart" returnType="boolean">
          <cfargument type="String" name="targetPage" required=true/>
          <cfoutput>Uppercase Application.cfc ran at #now()#</cfoutput>
          <cfreturn true>
      </cffunction>

</cfcomponent>

application.cfc
<cfcomponent output="false">
      <cfset this.name = "LowerCaseA">
      <cfset this.sessionManagement = true>
      <cfset this.sessionTimeOut = createTimeSpan(0,0,0,15)>

      <cffunction name="onRequestStart" returnType="boolean">
          <cfargument type="String" name="targetPage" required=true/>
          <cfoutput>Lowercase application.cfc ran at #now()#</cfoutput>
          <cfreturn true>
      </cffunction>

</cfcomponent>

Add a simple test page in that same directory and run it.  

    Test.cfm
    Time <cfoutput>#now()#</cfoutput>

It should output the time and "Uppercase Application.cfc ran at {time now}
0
 
Brijesh ChauhanStaff IT EngineerCommented:
Linux is Case sensitive, so on linux, application.cfc and Application.cfc are DIFFERENT files. Coldfusion requires the one with Capital A.

http://blog.critical-web.com/blog/index.cfm/2008/11/2/Linux-and-Applicationcfc
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
Brijesh ChauhanStaff IT EngineerCommented:

How do I know which one to mess with - without potentially screwing something up?



Go to CF Administrator, enable debugging, add your IP address. Then in the debug info you can see which file is called, it would be with the capital A.

Remeber linux is case sensitive for everything, so index.cfm and Index.cfm are different files, similarly, CFIDE and cfide are different directories...
0
 
_agx_Commented:
Enabling debugging is fine for a test server, but don't enable it on a production site.
0
 
gdemariaCommented:
> Can someone explain to me the hierarchy of how "APPLICATION" is handled

regarding the hierarchy..

Start with the file is being executed, that directory is checked first for an applicaton.cfm/.cfc file.  If not found, it tests the folder above and above until it gets to the root.   If the file is found, it no longer searches for another.

If both Application.cfc and .cfm exist, the Application.cfc is used over the .cfm file.

0
 
erzoolanderAuthor Commented:
Okay - thanks for the info.

So - next question...

I *think* what they were doing is keeping one copy of "Application" as the main file - for the production server - and one file as "application" as the backup for the testing server.

I think the previous developer screwed something up by downloading one of the files to his windows work environment (which is not case sensitive obviously) and then re-uploading it again...not realizing that he was working with two different files.

(i.e., if I FTP "Application.cfc" to my windows desktop... and then I download "application.cfc" to my desktop...it'll replace the file...but leave the Application.cfc filename in tact.  Second file "application.cfc" then becomes "Application.cfc" upon next upload).

On the testing server - things are all mucked up - components aren't being found - etc.  Do you think my guess as to what happened is reasonable?
0
 
gdemariaCommented:

That's possible, but sometimes it's difficult to figure out how you got someplace, but you just need to figure out how to get home.

I would look at your webroot and determine what application.cfm/cfc files you have there, if there is more than one, determine which is the right one and remove the others.   Put in a little message as agx suggest, or enclose it a CFIF testing for your IP address (so it's only visible to you) <CFIF cgi.REMOTE_ADDR is "111.111.11.11"><h1>THIS ONE</h1></cfif>

If you need to compare the files, this is a great utility for side-by-side comparisons.  It gives you lots of free use under the trial..

http://www.scootersoftware.com/download.php

0
 
Brijesh ChauhanStaff IT EngineerCommented:
Yes, You are probably correct, case sensivity is an issue on Linux, as much as is the permissions of directories and files. Would also need to check the owner and groups...

We also faced a similar issue when we migrated from windows to Linux box....

Again as suggested earlier you can enable debugging, add YOUR IP address so that it is visible to you and check the files in the debug which are executed. You can trun off the debugging once you are done with testing.
0
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
Can u Please Upload ur Application.cfc which is u are using now so we can check it properly what causing the trouble
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now