getContextRoot
Description
Returns path to the J2EE server context root for the current request.
Categories
Related
History
ColdFusion
MX 7: Added this function.
Syntax
GetContextRoot()
Returns
The
path from the web root to the context root for the current page.
The path starts with a forward slash character (/) but does not
end with a forward slash character (/). For applications in the
default (root) context, returns the empty string.
Usage
This function is equivalent to calling GetPageContext().GetRequest().GetContextPath(). On J2EE configurations, it returns the path from the Web root to the J2EE context root of the ColdFusion J2EE 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 J2EE context roots.
This function is useful in applications that might be installed at varying J2EE 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>