Home / code / asp

Response object,

The most important methods :

Response.Write
Can be replaced by <%= %> writes the data between quotes to the browser, the data can contain constants and variables.
Response.End
Stops the translation of the page and sends it to the browser.
Response.Redirect
gives the control to another page, you need to add the buffer-command, so the data is only send at the end of the HTML-page.
Response.Flush
Sends the output immediately to the browser.
Response.Clear
Removes the bufferdata, the browsers shows nothing from the already produced HTML-code.

The most important properties :

Response.Buffer
Used with the Clear-method, you can prevent data from being shown.
Response.Expires
Gives the number of minutes the page must stay in the cache.
Response.ExpiresAbsolute
Tells till which data the page must stay in the cash.
Response.ContentType
Gives the HTTP-content type for the page.

 

Response.Write

For more info go here

If we need to send a lot of data to the browser it can take some time. If the user has to wait to long for any sign of information he will surf to another page. With a buffer you can send data to the browser while ;building the page.

Response.Buffer

With the instruction response.buffer=true the buffer is activated. All response.write instruction send their data to the buffer.

Response.Flush

When the buffer is activated, you can, with this command send data in the buffer to the browser.

Response.Clear

With this command you can delete the data in the buffer.

Example:

<% @language=vbscript %>
<% response.buffer=true %>
<HTML>
<HEAD><TITLE>Example</TITLE></HEAD>
<BODY>

<%
response.write("You don't see this")
response.clear
response.write("first line<br>")
response.second line<hr>")
response.write("here the user already get the info")
response.flush

for i=0 to 2000000
next
response.write("<br>here is the rest")
%>

</BODY>
</HTML>

Response.End

With this command the script is halted end all data in the buffer is send to the browser.

While surfing all HTML-pages( and pictures) you visit are stored in the cache on your PC. If the users visits a page that is already in the cache, it checks the expire-date/time. If the date isn't expired the page is loaded form the cache.

Response.Expires

With this command you set after how many minutes the page expires. If the page must expire immediately, you set the value to 0
response.expires=minutes

Response.ExpiresAbsolute

With this command you set a date and/or time when the page must expire. If the page must expire immediately, you set the data on yesterday
response.expiresabsolute=#datumtime#

Response.Redirect

You can let the control over the program to another page. Response.Redirect does not work without Response.Buffer

Example: The next program will check which day it is end send the user to the page.

<% @language=vbscript %>
<% response.buffer=true %>
<HTML>
<HEAD><TITLE>Example on response.redirect</TITLE></HEAD>
<BODY>

<%
whichday=weekday(now())
response.write("the day of the week is "& whichday &"<HR>")
select case whichday
  case vbWednesday
	response.write("wednesday")
	response.redirect("05.html")
end select
response.write("<hr>")
%>

</BODY>
</HTML>

The following is then send to the browser

<HTML>
<BODY>
<H1>Wednesday</H1>
</BODY>
</HTML>

 

TOP

Latest script:

 

Books: