Home | » | ASP | » | Using the Response Object |
Using the Response Object
The Response object used for sending output which might be text, cookie data etc to the user from the Server. It has serveral methods and properties. Through its methods and properties you will learn how the output to be sent to the user can be controlled. Using the cache control property you can instruct the proxy whether to cache or not to cache.
Contents
What is Response Object?
Response object is one of the seven built in Asp object which is used for Sending output on Client's Computer The output Might be text or either be Cookies and Either be a Tag With the Help of Response Object We Send any type of data to Client's web browser and it also control how information should be sent to browser and It has certain set of Properties and Methods For Sending Results to Client there are two different ways First by using write Method and Second by using Shortcut Method .
Dissecting the Response Object
Response allows you to send information to the browser and control how information is sent to the browser. It has several methods and properties.
Sending HTML to the Browser
The most common use of the Response object is to send data to the client's Web browser to be displayed as part of a web page. It does this in two different ways. The first is to use the write method and the second is shortcut <%=...%> .
Response.Write
This Method is Mostly used for Sending output on Clients Web browser and With the help of Response.write One can Display a Message and a Value of Variable in same time and Response.write also has some ability to Execute Any Tag of HTML But For Executing any tag html a User have to Write a Tag into double quotes and also he may set various attributes of tags For Example :-
Response.Write ("Welcome To ASP ")
Output
Welcome To ASP
Using Shortcut
The Shortcut Method is Written with the help of <% =%> This is Used when we wants to display Results of a Function and When we wants to print only Some Values and not Message With the help of Shortcut Method one cannot display Message Along with values For Example :-
<% =now()%>
Will Display date and time of System.
Output
<%=now()%>
Buffering ASP Pages
A Client Can Send Results directly on client web Browser or Either he may able to Control how and when Information output sent to Client. Output can be sent in two different ways either Buffered or Unbuffered Buffered output doesn't display until a Special Command is given by Script and Un-buffered output is sent directly to Client Web browser when we uses a Response.write Method.
Response.Buffer
A Client Will Request For a Web Page Then all the Processing is to done by server Buffered is used when user to perform some type of Operation and when a user wants to faster Acessing of date that is Stored on Server When Clients Will on the Buffer then all the data is not Directly displayed to Client borwser rather whole Results will be stored on Client 's Buffer So that when a Client Request For Same data then Server will not Processed any data either whole data will be picked from Client buffer For Turning on Buffer a client has to Set the property Response.buffer to true at the Top of Script and After Processing Instruction Line Like
Response.buffer=True
By Default Buffer Property is False
Example: Response.Buffer
Response.Clear
The Response.Clear Method is used when a user has wash out his Buffer or when a client wants to Remove all the Data From buffer When Response.clear Will put into Script then All the data from client's buffer will be Removed But Always Remember when you use this Method nothing will be displayed on client 's Browser because all the Data is First Sent to Client's buffer and then to Web Browser When you use this Method then all the data will be lost and Web Browser will not able to see any Contents So This is advisable to you , use Response.clear Method at the End of Script or When you Wants to End you Script.
Example: Response.Clear
Response.Flush
We know that for clearing the Contents of Buffer we can use Response.clear Method but when you Clear the buffer then all the Contents of buffer will be lost and a user will not be able to see all the contents of buffer so that Response.flush which is also used for clearing the contents but when you use flush method it first display the contents those are stored in buffer and then this will clear all the contents from buffer All Contents are First Displayed on Client's web browser then buffer will be washed out.
Example: Response.Flush
Response.End
This Method is used for Endhing or halting the Code of Script By Using Response.end The Script Engine will no more Executed or Server will Doesn't Execute Any Code of Asp After Putting All Statemnets of Response.End Wherever you put the Response.End All The Script Will be End there and No More Statement will be Executed.
Example: Response.End
Response.Redirect
This Method is used for Sending a User ontoAnother ASP Page Redirect Method is Used When Asp Has no Asp Page that was Requested by User So that the ASP Engine Will Display another Page of ASP But Always Remember Another Page is Always Requested by ASP Page.
Example: Response.Redirect (verify.asp)
Example: Response.Redirect (members.html)
Cookies
Whenever a user Send a Request to Server For a Particular Page Then not URL is Send to Server but also Some Additional Information is Send Along with the URL Like Name of Browser that is currently used by Client For Making a Request , name of Computer ,language known and name of server all this Additional information is send along with ASP Request and also it determines date and Time When the Request was made All this Such information is Stored into the Cookies. These are Temporary File those are made on Client's Computer. Server Doesn't maintain any information about the clients Because there are So Many Users those Requests For a Page From Server so it is very hard for a Server to maintains all the Information about all the Clients.
Response uses a Expire Property Which Determines When Cookies are Deleted from System For This Pupose Expire Property of Response Specify how long page should be cached and Response.Expires =5 denoted that Cookies will deleted after 5 minutes so that Response.Expires Will Accept Minutes for Removing the Cookies From System and
For This Purpose Response uses ExpiresAbsolute Property For Giving Exact Time of Expiration of Cookie Like Specific date and Time For Cookie Expiration Like Response.ExpiresAbsolute=dateadd("d",14,date()) This example Will Shows that Cookies will Expires After 16 days of Current date.
Blogger Comment
Facebook Comment