Use of ASP request objects

Source: Internet
Author: User

ASP mainly has five built-in (built-in) objects: Server, Request, Response, application and session. Now we'll explain them by example. The first is the most commonly used response object.

Example 1 using response to output HTML documents in a Web page

     
     
      
      
 


You can enter the above code in FrontPage Editor, or WordPad, Notepad, and so on, and then save as example1.asp, the file name can be anything else, but the extension (or suffix) must be. ASP. The previous example uses the "write function" of the response object to send HTML code to the client's browser, and the browser on the client computer displays the following list:





      
       
        
       · My name is Jack. · I am from America. · and I love.
      
       



In fact, these HTML code can be written directly in the ASP file, and do not have to use Response.Write to output, in general, variables or some of the changed data to use Response.Write to output. In addition, we can use <%= data or variable%> to output information, and its effect is equivalent to Response.Write.





Example 2 uses response and <%= data%> to output the calculated results from 1 to 100 in the Web page





      
       
        
       



The above example does not indicate that the use of VB Script scripting language, because the ASP default is VB Script, if you want to use Java script, you can in the top line of ASP in the statement





      
       
        
       "<%@ language=jscript%>"
      
       



specified. Note that there must be a space between the symbol "@" and "LANGUAGE". Once you have indicated it, you can use JavaScript as you please. For example 2, we can use JavaScript to do this.





Example 3 uses JavaScript and &lt;%= data%&gt; to output calculations from 1 to 100 in a Web page





      
       
        
       



in this case, we used a flag pair and marked the use of the JavaScript scripting language, unlike the HTML document, where the statement runat= "server" in the flag pair indicates that the script is running on the server side, Instead of being routed to the client's browser, the explanation runs later. To prove this is simple, view the source code in the browser, you will not see the





      
       
        
       <script language= The Code section of the "JScript" runat= "Server" >......</script> and <%......%>
      
       
In addition to the "Write" function, Response also has "End method": Response.End. It is used to end the output of a Web page and the running of server-side scripting programs. Readers can attempt to use this "End method" themselves.   Okay, next tutorial we'll talk about the powerful request-for-build (built-in) object in ASP.

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.