# Interceptor Output Buffer

Every interception point receives a unique request output buffer that can be used to elegantly produce output. Once the interception point is executed, the interceptor service will check to see if the output buffer has content, if it does it will advice to write the output to the ColdFusion output stream. This way, you can produce output very cleanly from your interception points, without adding any messy-encapsulation breaking `output=true` tags to your interceptors. (**BAD PRACTICE**). This is an elegant solution that can work for both core and custom interception points.

```javascript
// Using methods, meaning you inherited from Interceptor or registered at configuration time.
function preRender( event, data, buffer, rc, prc ){
    //clear all of it first, just in case.
    arguments.buffer.clear();
    //Append to buffer
    arguments.buffer.append( '<h1>This software is copyright by Funky Joe!</h1>' );    
}
```

> **Hint** Each execution point will have its own clean buffer to work with. As each interception point has finalized execution, the output buffer is flushed, only if content exists.

## Output Buffer Argument

Here are some examples using the `buffer` argument:

```javascript
function onSidebar( event, data, buffer, rc, prc ){
    savecontent variable="local.data"{
        /// HTML HERE
    }

    arguments.buffer.append( local.data );
}

// using argument
function preRender( event, data, buffer, rc, prc ){
    //clear all of it first, just in case.
    arguments.buffer.clear();
    //Append to buffer
    arguments.buffer.append('<h1>This software is copyright by Funky Joe!</h1>');    
}
```

Here are some common methods on the buffer object:

* `append( str )` Append strings to the buffer
* `clear()` Clear the entire buffer
* `length()` Get size of the buffer
* `getString()` Get the entire string in the buffer
* `getBufferObject()` Get the actual java String Builder object


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coldbox.ortusbooks.com/the-basics/interceptors/interceptor-output-buffer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
