Whatever message this page gives is out now! Go check it out!

Response interface

Last update:
May 18, 2026
public abstract interface Response
Interface to response generated from a custom tag. This interface includes methods for writing output, generating queries, and setting variables in the calling page.

Methods

ReturnsSyntaxDescription
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.

addQuery

Description

Adds a query to the calling template. The query can be accessed by CFML tags in the template. After calling addQuery, the query is empty (it has 0 rows). To populate the query with data, call the Query methods addRow and setData. Returns the Query that was added to the template.

Category

Syntax

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

Throws

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

See also

addRow,  setData

Parameters

ParameterDescription
name
The name of the query to add to the template
columns
The column names to use in the query

Example

The following example adds a query named People to the calling template. The query has two columns (FirstName and LastName) and two 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" ) ;

setVariable

Description

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.

Category

Syntax

public void setVariable(String name, String value)

Throws

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

Parameters

ParameterDescription
name
The name of the variable to set
value
The value to set the variable to

Example

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

write

Description

Outputs text back to the user.

Category

Syntax

public void write(String output)

Parameters

ParameterDescription
output
Text to output

Example

The following example outputs the value of the DESTINATION attribute:
response.write( "DESTINATION = " + request.getAttribute("DESTINATION") ) ;

writeDebug

Description

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

Category

Syntax

public void writeDebug(String output)

See also

Parameters

ParameterDescription
output
The text to output

Example

The following example checks whether the debug attribute is present; if so, it writes a brief debug message:
if ( request.debug() ) { response.writeDebug( "debug info" ) ; }

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page