Solved

Coldfusion Naming Conventions

Posted on 2011-02-25
10
316 Views
Last Modified: 2012-05-11
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
Comment
Question by:erzoolander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34983052
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
 
LVL 52

Expert Comment

by:_agx_
ID: 34983246
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
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 34983261
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 34983420

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
 
LVL 52

Expert Comment

by:_agx_
ID: 34983459
Enabling debugging is fine for a test server, but don't enable it on a production site.
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 34983661
> 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
 
LVL 2

Author Comment

by:erzoolander
ID: 34985308
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
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 34985539

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
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 34985830
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
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 34990008
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question