Name
Flush —
Response.Flush
Synopsis
Immediately sends all data currently in
the response buffer to the client. Unless the Buffer property of the
Response object is set to True
, this method will
result in a runtime error. This method allows you to send various
portions of the response to the client at your discretion.
Parameters
None
Example
<% Response.Buffer = True%> <HTML> <HEAD><TITLE>Response Flush Method Example</TITLE></HEAD> <BODY> <% ' Suppose for this example that this first part of the ' script retrieves some information from a database and ' that retrieval takes a long time, say 30 seconds. ' (Don't worry about the details of the ActiveX Data Object ' calls. They are covered later in the book and serve only ' as an example here of something that might take a long time.) Set adoCon = Server.CreateObject("ADODB.Connection") adoCon.Open MyDatabase Set adoRec = adoCon.Execute([BIG SQL STATEMENT]) ' Rather than continue to the second part of the script, in ' which a second slow SQL statement (say another 15 seconds) ' executes, first we'll use the Flush method to force the ' first part of the script results to the client. This way, ' the user can be looking at the results of the first query ' while waiting for the second. Response.Flush ' [Second LONG SQL statement.] Set adoRec2 = adoCon.Execute([BIG SQL STATEMENT]) %> </BODY></HTML>
Notes
Using the buffering capacity of the Response object, you are able to send the response to the client in parts. For example, suppose you are ...
Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.