Adobe ColdFusion 8

GetPageContext

Description

Gets the current ColdFusion PageContext object that provides access to page attributes and configuration, request, and response objects.

Returns

The current ColdFusion Java PageContext Java object.

Category

System functions

Function syntax

GetPageContext() 

History

ColdFusion MX: Added this function.

Usage

The ColdFusion PageContext class is a wrapper class for the Java PageContext object that can resolve scopes and perform case-insensitive variable lookups.

The PageContext object exposes fields and methods that can be useful in J2EE integration. It includes the include and forward methods that provide the equivalent of the corresponding standard JSP tags. You use these methods to call JSP pages and servlets. For example, you use the following code in CFScript to include the JSP page hello.jsp and pass it a name parameter:

GetPageContext().include("hello.jsp?name=Bobby"); ===

When you use GetPageContext to include a JSP page in a CFML page on WebLogic, you may need to flush the output of the CFML page with cfflush before calling the JSP page. Otherwise, the ColdFusion output appears after the JSP output.

The methods supported on the returned PageContext are only those mandated by the JSP specification. To look up scopes by name, use the StructGet function, for example:

<cfset myscope = "server">
<cfset myserver = StructGet(myscope)> 

For more information, see your Java Server Pages (JSP) documentation.

Note: On Weblogic, you may need to flush the output of the CFML page (using cfflush) before calling a JSP page. If you do not, the ColdFusion output appears after the JSP output.

Example

<!--- This example shows using the page context to set a page 
    variable and access the language of the current locale. --->
<cfset pc = GetPageContext()>

<cfset pc.setAttribute("name","John Doe")>
<cfoutput>name: #variables.name#<br></cfoutput>

<cfoutput>Language of the current locale is
    #pc.getRequest().getLocale().getDisplayLanguage()#</cfoutput>.