Solved

Coldfusion Naming Conventions

Posted on 2011-02-25
10
308 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
  • 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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 1

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 15

Expert Comment

by:myselfrandhawa
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now