Javascript asp tutorial Lesson 7-response attributes

Source: Internet
Author: User

Below is a table of Response Properties along with examples and explanations.

Response Properties
Buffer Response. Buffer = true
Allows for the buffering of output
CacheControl Response. CacheControl = "Public"
Sets Cache to "Public" or "Private"
CharSet Response. CharSet = "windows-1252"
Sets the ISO character set
ContentType Response. ContentType = "text/HTML"
Specifies the output mime type (text/html, text/plain, GIF, JPG)
Expires Response. Expires = 60
Sets page expiration in minutes
ExpiresAbsolute Response. ExpiresAbsolute = # January 31,200 3 13:00:00 #
Sets time certain for page to expire
IsClientConnected If (Response. IsClientConnected = true ){}
Determines if client is still connected
PICS (See Explanation ))
Platform for Internet Content Selection
Status Response. Status = "401 Unauthorized"
Sets Page Status

You are not required to set, alter, or utilize a single Response Property if you don't want. having said that, they can be handy once in while. I 've demonstrated all but two Properties in the script below.

By the way, set your properties BEFORE you begin output to the client.

Get Started:

Below is the ASP script for Lesson 07.

<%@LANGUAGE="JavaScript"%><%Response.Buffer=trueResponse.CacheControl="Private" Response.CharSet="windows-1252"Response.ContentType="text/HTML"Response.Expires=-1Response.Status="200 OK"%><HTML><BODY><%if (Response.IsClientConnected==true){Response.Write("The client is connected.<BR>")}else{Response.End()}%><TABLE BORDER="2"><TR><%for (x=1;x<=200;x++){Response.Write("<TD>" + x + " </TD>\r")if (x%10==0){Response.Clear()}if (x%4==0){Response.Write("</TR></TABLE>\r")Response.Write("<TABLE BORDER=\"2\">")Response.Write("\r<TR>")Response.Flush()}}%></TR></TABLE></BODY></HTML>

Click Here to run the script in a new window. After you click onto the link, really study the numbers. See if you notice anything weird about the page, like missing numbers.

Response. Buffer:

Let's take the Properties in order of appearance in our script. response. buffer allows us to control the output via Response. flush () and Response. clear (). if you haven't already, click onto the link to run the script. you'll get a strange output with some of the numbers missing. the missing numbers are thanks to Response. clear (). you might notice that Response. flush () slows down the server TREMENDOUSLY. don't use this method without a reason.

Response. CacheControl:

CacheControl gives you the power to authorize proxy servers to keep your page in cache. (That wocould be the "Public" setting .) likewise, it allows you to disallow proxy servers from caching your page. (That wocould be the "Private" setting ). the default is "Private."

Response. CharSet:

CharSet allows you to specify the character set, for example: "ISO 8859-1 ".

Response. ContentType:

ContentType allows you to indicate the mime type of the output. For example there is text/plain and text/html. There is also GIF and JPEG.

Response. Expires:

Expires allows you set an expiration time for the page. by setting the Expires property to-1, you are saying the page expired one minute before it was delivered. the browser will (hopefully) not store it in cache, but rather make a separate request to the server before re-displaying the page.

Response. Status:

If tomorrow Congress were to pass a law forbidding the use of Response. Status, I think life wowould go on. If it makes you happy, use it.

Response. IsClientConnected:

IsClientConnected does exactly what it says. It returns a Boolean value that you can use in an "if" statement.

Response. PICS:

PICS stands for Platform for Internet Content Selection. it allows pages to be rated for the presence of violence, sexuality, language and nudity. there are services on the internet to rate your site. I 've never used one. I found a sample PICS string on the internet and I converted to JavaScript.

Response. PICS ("(PICS-1.1

It's a long string and your browser may have wrapped the text down to a second line. if that's the case, then you have to pretend that the entire PICS string is on one line.

Response. ExpiresAbsolute:

I did not demonstrate ExpiresAbsolute in the script because I already used Response. expires. expiresAbsolute does exactly the same thing as Expires, doesn't it uses a date and time certain. (I couldn't see using both in the same script .) the only thing I wocould point out is the pound signs (#) at the beginning and of the date.

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.