The Response object in Classic ASP controls the HTTP response sent to a visitor: text and HTML output, buffering, redirects, headers, and when processing ends. Choose the method that matches what the server must do.
The most common starting point is Response.Write:
<%
Response.Write "Hello from Classic ASP!"
%>
Output: Hello from Classic ASP!. Save the snippet in a .asp page on an IIS site with Classic ASP enabled; the enclosing page template is written in PHP only for the Plus2Net website.
| Method | What it does | Example tutorial |
|---|---|---|
Response.Write | Adds text or markup to the response body | Write output |
Response.Flush | Sends currently buffered output while continuing processing | Flush output |
Response.Clear | Discards output still in the ASP buffer | Clear output |
Response.End | Stops processing this ASP file and returns its current result | End processing |
Response.Redirect | Tells the browser to request a different URL | Redirect |
Response.Buffer | Controls whether ASP holds body output before sending it | Buffering guide |
<%
Response.Write "Welcome to Plus2Net"
Response.Write "<p>Learn Classic ASP step by step.</p>"
%>
The first statement writes text; the second writes an actual HTML paragraph. Response.Write does not automatically add a newline or encode visitor-provided text.
<%
Dim visitorName
visitorName = Request.QueryString("name")
Response.Write "<p>Hello, " & Server.HTMLEncode(visitorName) & "</p>"
%>
Use Server.HTMLEncode() for text placed inside HTML elements. Attribute values, JavaScript, CSS and URLs have separate encoding and validation needs; do not treat HTML encoding as a universal sanitizer.
<%
Response.Buffer = True
Response.Write "This first message is sent.<br>"
Response.Flush
Response.Write "This second message is discarded.<br>"
Response.Clear
Response.Write "This final message is returned.<br>"
%>
The first message has already been flushed, so Response.Clear cannot remove it. The second is cleared before delivery; the final message is sent when the ASP page completes.
<%
Response.Write "Before End"
Response.End
Response.Write "Never executed"
%>
Once the End method runs, the remaining statements in that ASP file are skipped.
<%
Response.Redirect "/asp-tutorial/response-write.php"
%>
A redirect must occur before the HTTP headers have been committed. If you are deciding whether to redirect after a login or form submission, perform that decision before writing or flushing page content.
With buffering enabled, ASP can hold page output until completion. Calls to Flush transmit pending output and can commit headers; Clear removes pending output; End stops execution. In current IIS Classic ASP configuration, buffering is normally enabled unless changed by an administrator. See Response buffering.
Response methods. Do not copy ASP.NET examples such as Response.Redirect(url, false), CompleteRequest(), or Server.Transfer() into a VBScript Classic ASP lesson; their APIs differ.| Goal | Use |
|---|---|
| Print a variable | Response.Write |
| Send partial buffered output before work finishes | Response.Flush |
| Discard unsent markup before replacing it | Response.Clear |
| Stop the current page immediately | Response.End |
| Move the browser to another address | Response.Redirect |
If a redirect reports a header error, check whether output has already been flushed. If Flush reports buffering off, enable buffering before sending content. If HTML characters supplied by a visitor become active markup, encode the value for its HTML output context. If code after End is not executed, that is expected.
With buffering enabled, it normally adds output to the buffer. The server sends it later or when Response.Flush is called.
No. It can only discard output still buffered on the server.
No. It tells the client to make a new request at the target URL; it is not a server-side include.
Yes. Use Response.Write to send trusted markup or HTML-encoded text.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.