Contents > CFML Reference > ColdFusion Java CFX Reference > Response interface > setVariable PreviousNext

setVariable

Sets a variable in the calling template. If the variable name specified exists in the template, its value is replaced. If it does not exist, a new variable is created.

Response interface

public void setVariable(String name, String value)

IllegalArgumentException If the name parameter is not a valid CFML variable name.

Parameter

Description

name

The name of the variable to set

value

The value to set the variable to

For example, this code sets the value of a variable named MessageSent based on the success of an operation performed by the custom tag:

boolean bMessageSent ;

   ...attempt to send the message...

   if ( bMessageSent == true )
   {
      response.setVariable( "MessageSent", "Yes" ) ;
   }
   else
   {
      response.setVariable( "MessageSent", "No" ) ;
   }

Contents > CFML Reference > ColdFusion Java CFX Reference > Response interface > setVariable PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.