Skip to main content
Known Participant
June 18, 2007
Question

application.cfm vs index.cfm

  • June 18, 2007
  • 2 replies
  • 1436 views
Hi what is the difference between application.cfm vs index.cfm?

What is the significance?

This topic has been closed for replies.

2 replies

June 18, 2007
Application.cfm is a "special" file. it is implicitly included before all page requests (assuming it exists).

index.cfm is not "special", but often set up in your web server (IIS, Apache, etc) as a "default document". a default document simply means if a user does not specify a particular page, this is the one that will load. in other words, if you simply type in " http://www.foobar.com", and 'index.cfm' is specified as the default document (again, within the web server), then the web server will deliver www.foobar.com/index.cfm. this default document can be anything (index.html, default.cfm, etc).

So assuming that your web server has index.cfm set up as a default document... here's the "relationship"...

- user requests http:///www.foobar.com/
- web server says, "hmm.. no specific document requested... deliver index.cfm, which is a coldfusion file... "
- coldfusion kicks in. says, "hey, i've been asked to deliver index.cfm... but first let me check for an Application.cfm" -if- an Application.cfm exists, ColdFusion will process it and -then- deliver index.cfm. if there is no Application.cfm, ColdFusion will simply deliver the index.cfm.

when Azadi says you cannot request Application.cfm on its own... that's what he means. try browsing directly to Application.cfm and you'll see that CF does not allow it.

Application.cfm generally should not have presentation code in it. Because it's implicitly pre-prended to all ColdFusion templates, it's a good place to put application-wide logic.

might want to read the docs on Application.cfm

http://livedocs.adobe.com/coldfusion/6.1/htmldocs/appfra10.htm

also, if you're on CFMX7, you might want to consider migrating to Application.cfc versus Application.cfm (but that's a whole nother subject) :)
Inspiring
June 18, 2007
they are totally different!

application.cfm is a special cf template. if present, it is always
processed before the requested cfm page. it is usually used to hold the
<cfapplication> tag which sets some application-scope settings, as well
as login procedures and setting other application-scope variables. you
CAN NOT request this template on its own. it is also not a good
practice to put any presentation code in the application.cfm (i.e. there
should be no html code or cfoutput'ed code in it).

index.cfm is just a regular cf template, which, like index.htm (and a
few other pages), will be presented to use, if present, if no specific
page has been requested.

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
susanringAuthor
Known Participant
June 18, 2007
What do you mean by you
CAN NOT request this template on its own.

Should not have Presentation code? You mean html that should be in dsp pages?


What else do you commonly put in the application.cfm?
Is this a standard?
<cfapplication> tag which sets some application-scope settings, as well
as login procedures and setting other application-scope variables.


how does index.cfm and appllication.cfm work together?


so the application.cfm is the first page that coldfusion looks for and

index.cfm is the first page that users sees?