Whatever message this page gives is out now! Go check it out!

GetContextRoot

Last update:
May 18, 2026

Description

Returns path to the JEE server context root for the current request.

Returns

The path from the web root to the context root for the current page. The path starts with a forward slash character (tick) but does not end with a forward slash character (tick). For applications in the default (root) context, returns the empty string.

Category

History

ColdFusion MX 7: Added this function.

Function syntax

GetContextRoot()

See also

Usage

This function is equivalent to calling GetPageContext().GetRequest().GetContextPath(). On JEE configurations, it returns the path from the Web root to the JEE context root of the ColdFusion JEE application. On server configurations, it returns the empty string, because the context root is at the web root.This function is useful in applications that might be installed at varying JEE context roots.

Example

The ColdFusion Administrator uses the following line to get the location of the administrator directory:
<cfset request.thisURL = "#getContextRoot()#/CFIDE/administrator/">
The Administrator uses the returned value in places where it uses a URL to access Administrator resources, such as images, as in the following line:
<a href="index.cfm"><img src="#request.thisURL#images/back.gif" width="16" 

height="16" border="0" alt=" "></a>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page