Q:

How to get the $_SERVER['DOCUMENT_ROOT'] in coldfusion?

In LAMP, I get the root of the website with
$_SERVER['DOCUMENT_ROOT']

as in /some/path/public_html
How do I get this, in coldfusion?
Update: I find that on this server, '/' is the doc root (and not the root of the whole file system, like LAMP)  Is that reliable?

A:

ColdFusion really has no idea where the 'web root' is, not should it really matter. I often architect applications where all my controllers, services and files are outside of the web root. What I tend to do in those cases where I actually need to know the web root I will create a ColdFusion mapping in my Application.cfc file that looks like this:
rootDir = getDirectoryFromPath(getCurrentTemplatePath());
this.mappings[ "/www" ] = rootDir;
this.mappings[ "/services" ] = rootDir & '../services';

This will create 2 ColdFusion mappings named www and services respectively pointing to the 'web root' (my www directory) and services directory above the web root. My directory structure would look something like this:

Site Directory 

wwwapp

services 
www (web root)

