This example demonstrates how you can manipulate the output buffer of the Response object using ASP. Unbuffered output written to the Response object is sent to the client browser as quickly as possible. If buffering is enabled, all output is allowed to accumulate in the buffer until it is either cleared or flushed (with the Clear and Flush methods respectively) or the script ends.
This sample script contains all the HTML elements required for two complete Web pages. If this script were run without any buffer management, both HTML pages would be sent to the client browser, causing an error. But for this sample, buffering is enabled at the very beginning of the script with the Response.Buffer property. ASP writes the first group of HTML elements it finds to the buffer, but then encounters the Response.Clear method, which instructs ASP to clear the Response object's buffer. The scripting engine continues through the file, writing the remaining, second, HTML page to the buffer. The entire buffer is then sent to the client browser with the Response.Flush method.
The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\interaction\Buffer_VBScript.asp and ...\asp\interaction\Buffer_JScript.asp.