Response Object Introduction To write an ASP page
Response Object
Introduction • To write an ASP page, all we need to do is write a standard HTML page, putting in the Active Server Pages script where needed. Active Server Pages script is denoted by the text between <%‘ content ‘%>. • Response object. It is the object which communicates between the server and the output which is sent to the client. Describes the methods, properties, and collections of the object that stores information related to the server's response. This includes displaying content, manipulating headers, etc.
Methods of Response Object • • Response. Add. Header Sets the HTML header name to value. Response. Append. To. Log Adds a string to the end of the Web server log entry for this request. Response. Binary. Writes the given information to the current HTTP output without any character-set conversion. Response. Clear Erases any buffered HTML output. Response. End Stops processing the. asp file and returns the current result. Response. Flush Sends buffered output immediately. Response. Redirect Sends a redirect message to the browser, causing it to attempt to connect to a different URL. Response. Writes a variable or text to the current HTTP output as a string.
Response. Write Method • Writes a variable or text to the current HTTP output as a string. Examples: • Example 1 (string) <% Response. Write "Hello World“ %> Output: Hello World • Example 2. a (string with HTML Tags) <% Response. Write("Hello<br/>World") %> Output: Hello World • Example 2. a (string with HTML Tags) <% Response. Write "<TABLE WIDTH = 100%>" %>
Response. Write Method • Example 3 (variables and concatenation operators) Int my. Num = 25; String my. String = "Hello"; Response. Write("my. Num = " + my. Num + "<br />"); Response. Write("my. String = " + my. String + " ");
Properties of Response Object • • • Response. Buffer Indicates whether page output is buffered. Response. Cache. Control Sets a header to notify proxy servers or other cache mechanisms whether they can cache the output generated by ASP. Response. Charset Appends the name of the character set to the content-type header. The character set specifies for the browser how to display characters. Response. Code. Page Sets the code page for data in the intrinsic objects for one response. The code page specifies for the server how to encode characters for different languages. Response. Content. Type Specifies the HTTP content type for the response. Response. Cookies Collection Specifies cookie values. Using this collection, you can set cookie values. Response. Expires Specifies the length of time before a page cached on a browser expires. Response. Expires. Absolute Specifies the date and time on which a page cached on a browser expires. Response. Is. Client. Connected Indicates whether the client has reset the connection to the server Response. Status The value of the status line returned by the server.
- Slides: 6