Notice: With the launch of Adobe Cookbooks, this site will no longer be accepting new entries or posting new content. Thanks to everyone who submitted content!

How do I do a server-side relocation?

ColdFusion provides a tag to handle relocating the user, <cflocation>. This tag returns header information to the browser that tells it to load a new URL. If you want to do a completely server-side relocation, you must use one of the underlining Java methods available in ColdFusion:

<cfset getPageContext().forward('url_here') />


This question was written by Hal Helms.
It was last updated on February 19, 2006 at 2:43:58 PM EST.

CFML Referenced

GetPageContext()
<cflocation>

Categories

Miscellaneous

Comments

Comment made by Jamie Price on February 19, 2006 at 7:33 PM
So what's the benefit of doing it this way vs. doing it with a CFlocation tag?


Comment made by Steve Gustafson on March 1, 2006 at 9:52 AM
The benefits include: 1) The ability to pass form and url and request variables to the new page.

2) CFLocation actually sets an HTTP status code of '302 Moved Temporarily' which can mess with search engines as well as log file reporting.

3) CFLocation negates the ability to set cookies.

There are other benefits as well, but these are the ones that come to mind.