Couple of Useful Custom Tags

It was pointed out the other day on a list that cfinclude doesn’t let you include JSP pages and that there is no cfforward tag to forward a request on to another resource (CFM, JSP, servlet, etc.). BlueDragon apparently does have this functionality. Well, now ColdFusion does, too, with the extremely simple tags below. And ColdFusion also has getPageContext(), as well.

<!---
The includeanything tag will include any type of page, not just a
CFM template.

@attribute page (required) Relative path to the template you want
to include.
--->
<cfif thisTag.executionMode is "start">
<cfparam name="attributes.page" />
<cfscript>
getPageContext().include(attributes.page);
</cfscript>
</cfif>

<!---
The forward tag will perform a server-side redirect.

@attribute page (required) Relative path to the template you want
to forward to.
--->
<cfif thisTag.executionMode is "start">
<cfparam name="attributes.page" />
<cfscript>
getPageContext().forward(attributes.page);
</cfscript>
</cfif>

2 Responses to Couple of Useful Custom Tags

  1. Hiroshi Fujihara says:

    Hi,I use same method in our application. When sender page send file data by multipart/form-data, server-side redirect can not run in the getter page. My test cfmx server is running on websphere5.

  2. Does this code also pass along the form variables? Charlie Arehart indicated that due to a bug in CFMX, that was not possible. Is this still true?