Response.Clear removes content that is still waiting in the ASP response buffer. It does not send that content to the browser. This differs from Response.Flush, which sends the current buffered output first.
Buffering must be enabled for this example. Current IIS Classic ASP configuration enables buffering by default unless the server configuration changes it.
<%@ Language=VBScript %>
<% Option Explicit
Response.Buffer = True
%>
<html><head>
<title>(Type a title for your page here)</title>
</head>
<body >
<%
Response.Write("Message No :1 Before Clear and Flush <br>")
Response.Flush
Response.Write("Message No :2 After Flush and before Clear <br>")
Response.Clear
Response.Write("Message No :3 After Clear and flush <br>")
%>
</body>
</html>
Here we will see two messages only. The Message No 1 and the Message No 3. Message No 1 will go to browser as we have used Response.Flush to send the data after this line. Then Message No 2 is written but after that Response.Clear command will remove it from buffer without sending it. The Message No 3 will reach browser once the script execution is completed.
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.
| tahzeeb | 26-04-2013 |
| thank. Bt i want an example of y n where do we use response.clear. Plz give a practical example. | |
| Larry De Angelis | 24-06-2015 |
| Thank you for the several helpful tips and tricks. I found them to be shoet and sweet, and they get right to the point. | |