ASP built-in object of the response object

Source: Internet
Author: User
Tags end flush client
response| Objects | built-in objects |

The response object is used to send data to the client browser that the user can use to send the server's data in HTML format to the user-side browser, which makes up a pair of objects to receive and send data, which is also the basis for dynamic implementation. The following describes its commonly used properties and methods.

  1, Buffer properties

This property is used to specify whether the buffer is used when the page is exported, and the default value is False. When it is true, the results are not exported to the browser until the entire active Server page execution ends. Such as:
<%Response.Buffer=True%>
<Head>
<title>buffer Example </title>
<body>
<%
For I=1 to 500
Response.Write (I & "<br>")
Next
%>
</body>
When this page executes, all of the contents of the entire home page are displayed in the browser at the same time, and the home page will be in the cache until the script finishes executing.

  2, Expires property

This property is used to set the length of time (in minutes) that the browser caches pages and must be refreshed on the server side. Use the following settings:
<%Response.Expires=0%>
By adding this line of code to the ASP file, you require that each request be refreshed because response will expire as soon as it receives the page.

  3. Write method

This method sends the data to the client browser, such as:
<%response.write "hello,world!" %>

4, redirect method

This method allows the browser to relocate to another URL so that when a client issues a Web request, the client's browser type is determined and the customer is relocated to the appropriate page. Such as:
<title>redirect Example </title>
<body>
<form aciton= "formjump.asp" method= "POST" >
<select name= "Wheretogo" >
<option selected value= "Fun" >Fun</option>
<option value= "News" >News</option>
<option value= "Sample" >Sample</option>
</select>
<input type=submit name= "Jump" value= "Jump" >
</form>
</body>
The above is the submitted form, and the following is the file that processes the form formjump.asp:
<%response.buff=true%>
<title>redirect Example </title>
<body>
<%
Thisurl= "http://www.webjx.com/"
Where=request.form ("Wheretogo")
Select case where
Case "Fun"
Response.Redirect Thisurl & "/fun/default.asp"
Case "News"
Response.Redirect Thisurl & "/news/default.asp"
Case "Sample"
Response.Redirect Thisurl & "/sample/default.asp"
End Select
%>
</body>
This example when the user selected, press the "Jump" button to submit the form, the server received the request after the call formjump.asp to locate the corresponding URL. But here's one thing to note that HTTP headers are already written to the client browser, and any changes to the HTTP headers must be made before the page content is written, as follows:
<@ language= at the beginning of the file. > Write After:
Response.buffer=true
At the end of the set:
Response.Flush
Here flush is a method of response, it must be the buffer property set to true to use, or it will produce a run mode error. The other clear method is also used to purge cached pages, and to use the Buffer property when set to True.

5. End method

This method is used to tell Active server to stop processing an ASP file when it encounters this method. If the response object's Buffer property is set to True, the end method sends the contents of the cache to the customer and clears the flushing area. So to cancel all the output to the customer, you can clear the buffer first and then use the End method. Such as:
<%
Response.buffer=true
On Error Resume Next
Err.Clear
If Err.number<>0 Then
Response.Clear
Response.End
End If
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.