I thought it might work to create a function that returned the url scope, but upon testing it, even with a local-scoped query (which prevents the function using the query itself) the use of url
inside the function is still corrupted:
<cffunction name="getUrlScope"><cfreturn Url /></cffunction>
...
<cfoutput query="x">
<cfif StructKeyExists( getUrlScope() , 'key' )>
<!--- still fails :( --->
There is however an undocumented (meaning unsupported and liable to change) option. If you dump getPageContext()
you will see a bunch of functions that do interesting things, including dealing with scopes.
You can use getPageContext().SymTab_findBuiltinScope('URL')
to get at the URL scope.
You can also use getPageContext().getCfScopes()
to get an array of scopes. I'm not sure if the order is guaranteed fixed but it seems to be [cgi,?,url,form,cookie,?] checking on both CF10 and cflive (CF9), so possibly is.
(In CF8 there was the method getBuiltinScopes, which returned a struct instead of an array - this no longer appears to exist, reinforcing the whole unsupported and changeable nature of these methods.)
On Railo those don't work, but there is getPageContext.UrlScope()
and similarly-named functions for the other scopes.