Write() | Binary write() | AppendToLog() | Buffer()property | Flush() method | Clear method |
End method | Expires property | Expires absolute | Cache control() | Redirect() |
Asp Response object
is used to send server’s output to the client.the Response object is the counterpart of Request
object,ie.In asp Request object collects information from the client and Response object
sends the information to the client by writing to the outgoing page.
Asp Response object Methods
and Properties
Response object – Write method
We have seen that
the primary function of response object is to send information back to the client.Write
methods of Response object is used to send information back to the client.The
syntax is:
Response.write
(information) .
The
information can be contents of server-variables,the return value from a function
, or a sting.
Suppose
we have a block of HTML code and we want to insert a single piece of ASP code
into it we can use shortcut method .The syntax is:
<%=
information%> .This is same as writing <%Response.write(information)%>
Response object – BinaryWrite()
The BinaryWrite method writes the specified information to the current
HTTP output without any character conversion. This method is useful for writing
non-string information such as binary data required by a custom application.The
Syntax is:
Response.BinaryWrite
data
Response object – AppendToLog()
The AppendToLog method adds a string to the end of the Web server
log entry for this request.In order for the specified string to be recorded in
the log file, you must enable the URI Stem option of the Extended Properties property
sheet for the site whose activity you wish to log. The Syntax is:
Response.AppendToLog
string
Response object – Buffer Property
Sometimes
we come across ASP scripts which takes long processing time.In this case we
can send some information to client , to let them know that the script is processing.There
is one property and three methods that will allow us to control the when the
output stream is send to the client.
Buffer
property is used to tell the ASP that we are manually controlling when the HTML
stream is send back to the browser.By default buffering is turned OFF.So first
we should turned it ON by inserting the following statement after language declaration
(if one is used) , but before any HTML written.the syntax is:
Response.Buffer
= true
Response object – Flush method
Flush
method sends any previously buffered output to the client immediately, but continues
processing the script.
This can be useful for displaying partial
results before your script finishes processing so that user does not get impatient
while waiting for the full results.
The syntax is:
<%Response.flush%>
Response object – Clear Method
This method erases
any already buffered HTML.It will erases the information that has been added
to the HTML since the last call to response.Flush.If you have not called response.Flush
, then it will erase all the information that has been added since the beginning
of the page ,except headers.The syntax is:
<%Response.Clear%>
Response object – End Method
This method causes
the server to stop processing the script and send the buffered output.The syntax
is:
<%Response.End%>
Response object – Expires property
This property
specifies the number of minutes before a page cashed on the browser expires.ie,
if the user returns to the same page before the specified number of minutes
the cashed version displayed.The syntax for setting this is:
<%Response.Expires
= minutes%>
Response object – ExpiresAbsolute
Using this property
we can set the date and(or) time at which page cashed on the browser expires.
<%Response.ExpiresAbsolute
= #DateTime#%>
Response object – CacheControl
If you set this
property to Public, proxy servers can cache the output generated by ASP.Setting
CacheControl to public may improve the perceived performance of your .asp files.
The default value is Private. The syntax is:
Response.CacheControl
=value
Response object – Redirect method
This method is
used to redirect to another page.The syntax is:
<%Response.Redirect%>
Please
note that calling redirect method after adding any information to HTML stream
will cause an
Error.