To send output to the user from the server, the ASP Response object is used.
A D V E R T I S E M E N T
Response Object
To send output to the user from the server,the ASP Response object is used. Its collections, properties, and methods are described below:
Collections:
Collection
Description
Cookies
Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified
Properties
Property
Description
Buffer
Specifies whether to buffer the page output or not
CacheControl
Sets whether a proxy server can cache the output generated by ASP or not
Charset
Appends the name of a character-set to the content-type header in the Response object
ContentType
Sets the HTTP content type for the Response object
Expires
Sets how long (in minutes) a page will be cached on a browser before it expires
ExpiresAbsolute
Sets a date and time when a page cached on a browser will expire
IsClientConnected
Indicates if the client has disconnected from the server
Pics
Appends a value to the PICS label response header
Status
Specifies the value of the status line returned by the server
Methods
Method
Description
AddHeader
Adds a new HTTP header and a value to the HTTP response
AppendToLog
Adds a string to the end of the server log entry
BinaryWrite
Writes data directly to the output without any character conversion
Clear
Clears any buffered HTML output
End
Stops processing a script, and returns the current result
Flush
Sends buffered HTML output immediately
Redirect
Redirects the user to a different URL
Write
Writes a specified string to the output
Write text with ASP
<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>
O/P:
Hello World!
Format text with HTML tags in ASP
<html>
<body>
<%
response.write("<h2>You can use HTML tags to format the text!</h2>")
%>
<%
response.write("<p style='color:#0000ff'>This text is styled with the style
attribute!</p>")
%>
</body>
</html>
O/P:
You can use HTML tags to format the text!
This text is styled with the style attribute!
Redirect the user to a different URL
<%
if Request.Form("select")<>"" then
Response.Redirect(Request.Form("select"))
end if
%>
<html>
<body>
<form action="demo_redirect.asp" method="post">
<input type="radio" name="select"
value="demo_server.asp">
Server Example<br>
<input type="radio" name="select"
value="demo_text.asp">
Text Example<br><br>
<input type="submit" value="Go!">
</form>
</body>
</html>
O/P:
Server
Example
Text Example
Demonstrates the use of the write method. To write to the browser.
<%@ Language=VBScript%>
<% strFileTitle = "Writing"%>
<%ifnotLCase(Request.QueryString("PageView")) = "source" then%>
<%ShowHeader strFileTitle%>
<%<
Response.Write "<HTML>"
Response.Write "<HEAD>"
Response.Write "<META NAME=""GENERATOR"" Content=""Microsoft Visual Studio 6.0"">"
Response.Write "</HEAD>"
Response.Write "<BODY>"
Response.Write "This example is done completely using Response.Write statement.<BR><BR>"
Response.Write "If you need to produce quotation marks you use """
Response.Write "</BODY>"
Response.Write "</HTML>"
ShowFooter
%>
O/P:
This example is done completely using Response.Write statement.