Page 252 - DCAP408_WEB_PROGRAMMING
P. 252
Web Programming
Notes The text is placed in the buffer and is not sent to the browser. The code continues and 20s later the
code completes. The text running query..as well as the result of the query are now sent to the
browser. Now look at the flow of this code block:
<%
Option explicit
Response.Buffer=false
Response.Write “running query..”
Dim conn
Dim RSTotalSales
Set conn=server.createobject (“adodb.connection”)
Conn.open “sales”, “sa”, “your password”
Set RSTotalSales=conn.Execute (“select Sum (TotalAmount) as_ TotalSales” _
&”from sales”
Response.Write RSTotalSales (“TotalAmount”)
%>
This time when the code gets here:
Response.Write “running query..”
The text is immediately sent to the browser. So now visitors receive the feedback that something
is happening while they are waiting for the query to run. This technique of giving the visitor
gradual feedback is very important for procedures that take more than a few seconds to complete.
Without the feedback, especially on the internet, visitors may assume something is wrong and
leave your site.
Response.Clear
Suppose you have buffering turned on. As your script is executing, output is being sent to the
buffer. Calling Response.Clear causes that buffer to be wiped out. In case, you have a page that
you do not want to be viewed under a special set of circumstances, it can be used.
Response.Flush
Like Response.Clear, Response.Flush flushes all the data from the system buffer. However,
Response.Flush first sends it to the client. This is useful Response.Clear, Response.Flush produces
an error message when buffering is turned off.
Response.End
Response.End ends execution of the script. If buffering is turned on and there is any buffered
data, it is sent. Any statements after the Response.End are not carried out. This is a more abrupt
end than simply allowing the script to end on its own, and so should be avoided if possible. It
can be useful, though, when problems (such as bad data) are detected to prevent them from
making things worse.
Task Give the answers to following questions:
1. Explain the concept of sending output buffered or unbuffererd.
2. Explain how the Response.Buffer property can be used to specify whether the current
page output should be buffered or not.
246 LOVELY PROFESSIONAL UNIVERSITY