ASP depth reveal (on)

Source: Internet
Author: User
Tags definition contains html form iis variables script tag variable
First, the basic knowledge of ASP

1. ASP is the abbreviation for active Server pages and is an interpreted scripting locale;
2. The operation of the ASP requires Windows operating system, the installation of PWS is required under 9x, and NT/2000/XP needs to install Internet Information Server (IIS);
3. ASP and JSP script tag is "<%%>", PHP can be set to a variety of;
4. The annotation symbol for ASP is "'";
5. Using additional components, you can extend the functionality of the ASP.

Example:

Helloworld_1.asp
<%= "Hello,world"%>

Effect:
Hello,world


Helloworld_2.asp
<%
For I=1 to 10
Response.Write "Hello,world"
Next
%>

Effect:
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world

Note: ASP is case-insensitive; variables need not be defined or used, the conversion is convenient; the grammar check is very loose.


Second, the use of ASP built-in objects:

You can use any of the following ASP built-in objects without having to specifically declare them in ASP scripts.

1. Request:

Definition: Can be used to access the request information sent from the browser to the server, which is used to read information about the HTML form that has been entered.

Set:
Cookies: Contains the value of the browser cookies
Form: Contains values from HTML form fields
QueryString: A value containing a query string
ServerVariables: Contains the values in the header and environment variables

Example:

Request_url.asp
<%
' Get user input and save in variable
User_id=request.querystring ("user_id")
User_name=request.querystring ("user_name")

' Determine if user input is correct
If user_id= "" Then
Response.Write "USER_ID is null,please check it"
Response.End
End If
If User_name= "" Then
Response.Write "User_name is null,please check it"
Response.End
End If

' Print variable
Response.Write user_id& "<br>"
Response.Write User_name
%>

Effect:
When you access http://10.1.43.238/course/request_url.asp?user_name=j:
USER_ID is null,please check it
When you access http://10.1.43.238/course/request_url.asp?user_name=j&user_id=my_id:
my_id
J

Thinking: How are variables passed in URLs and retrieved by ASP pages?


Request_form.htm
<style type= "Text/css" >
<!--
. Input {background-color: #FFFFFF; border-bottom:black 1px solid;border-left:black 1px solid; Border-right:black 1px so Lid;border-top:black 1px solid; Color: #000000; font-family:georgia; Font-size:9pt;color:midnightblue;}
a:link {color: #1B629C; Text-decoration:none}
a:hover {color: #FF6600; Text-decoration:underline}
a:visited {Text-decoration:none}
-->
</style>

<center>
<form name= "Course" action= "request_form.asp" method= "POST" >
User_id:<input type= "text" name= "user_id" maxlength= "" class= "input" ><br><br>
User_name:<input type= "text" name= "user_name" maxlength= "" class= "Input" >
</form>
<br><br>
<a href= "Javascript:document.course.submit ();" > Submit </a>
</center>

Request_form.asp
<%
' Get user input and save in variable
User_id=request.form ("user_id")
User_name=request.form ("user_name")

' Determine if user input is correct
If user_id= "" Then
Response.Write "USER_ID is null,please check it"
Response.End
End If
If User_name= "" Then
Response.Write "User_name is null,please check it"
Response.End
End If

' Print variable
Response.Write user_id& "<br>"
Response.Write User_name
%>

Note: How does the action of the form point to the difference between request_form.asp and request_url.asp on the source code?

2. Response:

Definition: Used to post messages back to the browser, which can be used to send output from the script to the browser.

Set:
Cookies: Add a cookie to the browser

Method:
End: processing of ending scripts
Redirect: Boot the browser to the new page
Write: Send a string to the browser

Property:
Buffer: Caching an ASP
CacheControl: Control caching by proxy server
ContentType: The content type of the specified response
Expires: Browsers control caching with relative time
ExpiresAbsolute: Browsers use absolute time to control caching

Example:

Response_redirect.asp
<%
' Go to Google and check it out.
Response.Redirect "http://www2.google.com";
Response.End
%>


Response_cookies.asp
<%
' Set and read cookies
Response.Cookies ("Time_now") =now ()
Response.Write Request.Cookies ("Time_now")
%>

Effect:
When you access http://10.1.43.238/course/response_cookies.asp:
2002-9-1 16:20:40


Response_buffer.asp
<% ' response.buffer=true%>
<a href= "a" >a</a>
<%response.redirect "Request_form.htm"%>

Effect:
①. Error accessing this page when the buffering function of IIS is turned off
A
Reply to object error ' ASP 0156:80,004,005 '
Head wrong
/course/response_buffer.asp, Line 3



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.