Page 257 - DCAP408_WEB_PROGRAMMING
P. 257
Unit 10: Working with Response Object
Response Object: The response object is one of the five built-in ASP objects. Response is used to Notes
send output to the client.
Response.Clear: This method clears any buffered HTML output.
Response.End: This method stops the current processing of the asp page and only returns the
result before this method.
Response.Flush: This method sends buffered output immediately.
Response.Redirect: This method can be used to redirect the user to another URL.
Response.Write: This method can be used to write out a variable or text.
Server.HTML Encode: Used to send text encoded so that the browser will not interpret it as
HTML.
10.7 Review Questions
1. Examine the difference between Response.Flush and Response.Clear?
2. Write a Response.Write statement to send <A HREF=”aboutme.html”> to the browser.
3. Write the code that sends the user to another page if it is an odd-numbered day and prints
a message if it is an even-numbered day.
4. Write a statement using Response.ExpiresAbsolute that is equivalent to the following:
(a) Response.Expires = 5
5. Write the code to have the cached version of the current page expire the first of the next month.
6. The response.write command is used to write output to a browser. Comment. Give a
program to support your answer.
7. Explain the ways in which HTML can be send to the browser using the Write method and
the shortcut method. Why is that when string is being written one cannot use %>?
8. Which one will result in an error: Response.Write (< HR LENGTH=30%> or <HR
LENGTH=30\>)? Which one is correct: Response.Write (< IMG SRC= “Trial.gif”>) or
Response.Write (“<IMG SRC= “”Trial.gif”” >”)?
9. Explain giving a few examples how you can use the Server.HTML Encode to send text
coded so that the browser does not interpret it as HTML. What is the shortcut < %=_%>
equivalent to?
10. When is it preferable to use the shortcut < %=_%> and when should you avoid using it?
What are the ways, as mentioned in the chapter, through which you can send the user from
one page to another?
11. What are cookies? How would place cookies on a visitor’s machine? What property of the
Response Object would you use to instruct the proxy whether to cache or not? What
happens when you set the CacheControl value to “private”?
Answers: Self Assessment
1. client 2. Response.AddHeader
3. Response 4. Web page
5. HTTP 6. Buffered
LOVELY PROFESSIONAL UNIVERSITY 251