Use of Response object in ASP tutorial

Source: Internet
Author: User
ASP has five built-in (built-in) objects: Server, Request, Response, Application, and Session. Now we will explain them through examples. The first is the most commonly used Response object.
Example 1 use Response to output HTML documents on the webpage
<Html>
<Head>
<Title> ASP Example 1 </title>
</Head>
<Body>
<%
Response. Write "<ul>"
Response. Write "<li> My name is Jack. </li>"
Response. Write "<li> I am from America. </li>"
Response. Write "<li> And I love China. </li>"
Response. Write "</ul>"
%>
</Body>
</Html>
You can enter the above code in the FrontPage Editor, or in a writer such as a WordPad or notepad, and save it as Example1.asp. The file name can be used, but the extension (or suffix) must be. asp. In the preceding example, the "Write function" of the Response object is used to send HTML code to the client's browser. The browser on the client displays the following list:
· My name is Jack.
· I am from America.
· And I love China.
In fact, these HTML codes can be directly written in ASP files without using Response. write to output. Normally, Response is used only for variables or some changed data. write. In addition, we can also use it to output information. Its function is equivalent to Response. Write.
Example 2 use Response and output the calculation result from 1 to 100 on the webpage
<Html>
<Head>
<Title> ASP Example 2 </title>
</Head>
<Body>
<%
DIM sum' defines the sum variable.
DIM I 'defines the circular variable I
Sum = 0
For 1 to 100
Sum = sum + I
Next I
%>
<P> from 1 to 100 </p>
<P> This is the result output using Response. Write: <% Response. Write sum %> </p>
<P> This is the result output by another method: <% = sum %> </p>
</Body>
</Html>
None of the above examples indicate that the VB Script language is used. At that time, because ASP is the VB Script by default, if you want to use Java Script, you can use statements in the top line of ASP.
"<% @ LANGUAGE = Jscript %>"
Specify. Note that there must be a space between the symbol "@" and "LANGUAGE. Once specified, you can use JavaScript as you like. For example 2, we can use JavaScript.
Example 3 use JavaScript and output the computing result from 1 to 100 on the webpage

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.