View comments | RSS feed

GetPageContext

Description

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

Returns

The current ColdFusion MX Java PageContext Java object.

Category

System functions

Function syntax

GetPageContext() 

History

ColdFusion MX: Added this function.

Usage

The ColdFusion MX 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.

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 will appear 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>>.

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


MaestroFJP said on Aug 1, 2005 at 11:43 AM :
FYI, CF deletes the pcQueryString variables if the getQueryString() returns nothings (essentially null or "").

<cfset var pcQueryString = getPageContext().getRequest().getQueryString() />

This is odd behavior - I'd expect pcQueryString = "" if the getQueryString() doesn't return anything.
cf.Objective said on Dec 16, 2005 at 4:44 PM :
Anybody, anybody... I've been told that getBuiltinScopes() is "an undocumented function" and shouldn't be used at risk of it breaking in future implementations... however, if the PageContext object is meant to be used for "performing case-insensitive variable lookups" how can things like it or SymTab_findBuiltinScope() be considered "undocumented" and/or "unsafe for future versions of CF"??

I'm in need of this functionality, especially from SymTab_findBuiltinScope() for a facade service I want to use to return a handle on a scope from a passed-in string, like "session" and it works... but if I can't rely on it, then I'm kinda up a polluted tributary.

This doco doesn't really give enough detail on what the PageContext can actually be used for, which of it's methods can be relied upon and so on... "it does lookups and also some stuff like forward() and include()" isn't quite specific enough for us to do anything with.

Thanks!

J
anuradha@radiusmedia.com said on May 16, 2006 at 12:36 AM :
i had actually pointed out in that thi9s function doesnot work for me.
but then i realised that i have been using the standardversion till then, and now we are using coldfusion for j2ee and now it works fine.
ASandstrom said on Jul 31, 2006 at 8:09 AM :
The methods supported on the returned PageContext are only those mandated by the JSP specification.

Tip: To lookiup scopes by name, simply use StructGet.
For example:

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

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000490.htm