Using Redirection


ColdFusion allows you to programmatically implement browser-side redirection using the <cflocation> tag. This tag has the two attributes shown in Table 5.1.

Table 5.1. <cflocation> Tag Attributes

ATTRIBUTE

DESCRIPTION

url

The URL the browser should be redirected to.

addtoken

An optional attribute that is either Yes or No. If the value is Yes, ColdFusion appends browser identification information to the URL you specify in the URL attribute. The default value is Yes.


See Chapter 6, "The Application Framework," and Chapter 11, "Session State Management," for further information on maintaining client state.


The url attribute is simply set equal to the HTML file or CFML template the browser should be redirected to.

TIP

A query string may be added to the end of the URL listed in the url attribute. This permits variables and their associated values to be passed to the redirection page.


The ADDTOKEN attribute warrants further explanation. Clients are identified in one of two ways:

  • If standard ColdFusion session state management is used, two variables are created: CFID and CFTOKEN. The combination of these two variables uniquely identifies a client.

  • If J2EE session state management is used, a single variable named jsessionid is used to identify clients.

If you are using session state management, the variables (whichever are used) must be present for each and every request. If you are redirecting requests with <cflocation>, the session identifiers should be added to the URL. Using addtoken="yes" ensures that the necessary values are appended.



Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net