What Is the Scope of a URL Variable?URL variables are not available for use on the page in which they are first defined. Rather, they are available on the page to which the link points. Because of this fact, using URL variables is the simplest way of maintaining state on a Web site. State refers to the capability of a Web server to remember things from one page to the next. For instance, local variables do not help the programmer maintain state because they are available only locally on the page in which they are created; they are not available on any other page in the Web site. URL variables allow you to pass information from one page to another when the user clicks a link. URL variables do not provide a total solution to the state problem because they have a limited scope. They are available only on the page to which they have been passed. After that page is processed by the ColdFusion server, the variables expire. However, while they exist, they can be used like local variables. TIP You can also create URL variables by using the <cfparam> tag. You usually do so on the page to which the link points in order to create a default value for a URL variable that is expected for the processing of the page. You can create URL variables this way: <cfparam name="URL.FName" default="Emily">
<cfparam> was introduced in Chapter 3, "Conditional Processing." |