This wasn’t always possible, and I don’t know when it become possible, but as I am working with Java CFX code now and am using this feature I thought I’d share.
The CFXAPI (used in creating CFX tags in C/C++ or Java) exposes a limited subset of the ColdFusion world to your code. One of the things is does allow is for the creation of variables and queries, typically a variable or query name would be passed to the CFX tag and the CFX code would create a variable or query of that name in the VARIABLES scope in the caller page. However, you are not limited to just using the VARIABLES scope. While CFX code itself is for the most part not really scope aware, if the query name (for example) passed to the tag were SESSION.data the data query will be created in the SESSION scope. In fact, even though the CFXAPI does not support structures, you could specify a variable using dot notation (like mystruct.myvar) and the variable created will indeed be a member of a structure.