# Interface Response

    public abstract interface Response

Interface to response generated from a CustomTag. This interface includes methods for writing output, generating queries, and setting variables within the calling page.

Method Summary
    Query
    addQuery(String name, String[]
    columns)
| Adds a query to the calling template.
    void
    setVariable(String name, String value)
| Sets a variable in the calling template.
    void
    write(String output)
| Outputs text back to the user.
    void
    writeDebug(String output)
| Writes text output into the debug stream.

## Method Detail

### write

    public void write(String output)

Outputs text back to the user.

The following example outputs the value of the DESTINATION attribute:

       response.write( "DESTINATION = " +
    request.getAttribute("DESTINATION") ) ;

#### Parameters:

`output` -- Text to output

### setVariable

    public void setVariable(String name,
                            String value)
                     throws IllegalArgumentException

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

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" ) ;
       }

#### Parameters:

`name` -- The name of the variable to set

`value` -- The value to set variable to

#### Throws:

`IllegalArgumentException` -- If the name parameter is not a valid CFML variable name

### addQuery

    public Query addQuery(String name,
                          String[] columns)
                   throws IllegalArgumentException

Adds a query to the calling template. This query can then be accessed by CFML tags within the template. Note that after calling addQuery the query exists but is empty (i.e. it has 0 rows). To populate the query with data you should call the Query member functions addRow and setData.

The following example adds a Query named 'People' to the calling template. The query has two columns ('FirstName' and 'LastName') and 2 rows:

       // Create string array with column names (also track columns
    indexes)
       String[] columns = { "FirstName", "LastName" } ;
       int iFirstName = 1, iLastName = 2 ;

       // Create a query which contains these columns
       Query query = response.addQuery( "People", columns ) ;

       // Add data to the query
       int iRow = query.addRow() ;
       query.setData( iRow, iFirstName, "John" ) ;
       query.setData( iRow, iLastName, "Smith" ) ;
       iRow = query.addRow() ;
       query.setData( iRow, iFirstName, "Jane" ) ;
       query.setData( iRow, iLastName, "Doe" ) ;

#### Parameters:

`name` -- The name of the query to add to the template

`columns` -- The column names to be used in the query

#### Returns:

The Query that was added to the template.

#### Throws:

IllegalArgumentException - if the name parameter is not a valid CFML variable name

#### See Also:

    Query.addRow,     Query.setData

### writeDebug

    public void writeDebug(String output)

Writes text output into the debug stream. This text is only displayed to the end- user if the tag contains the DEBUG attribute (you can check for this attribute using the Request.debug member function).

The following example checks to see whether the DEBUG attribute is present, and if it is then it writes a brief debug message:

       if ( request.debug() )
       {
          response.writeDebug( "debug info" ) ;
       }

#### Parameters:

`output` -- The text to output

#### See Also:

    Request.debug