ASP depth reveal (upper) (next)

Source: Internet
Author: User
Tags comments html form iis script tag

ASP depth reveal (on)
First, the basic knowledge of ASP

1. ASP is the abbreviation of Activeserverpages, is an interpretive scripting language environment;
2. The operation of ASP requires Windows operating system, 9x need to install PWS, and nt/2000/xp need to install Internetinformationserver (for short 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
<%
Fori=1to10
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
Ifuser_id= "" Then
Response.Write "User_idisnull,pleasecheckit"
Response.End
endif
Ifuser_name= "" Then
Response.Write "User_nameisnull,pleasecheckit"
Response.End
endif

' Print variable
response.writeuser_id& "<br>"
Response.writeuser_name
%>

Effect:
When you access http://10.1.43.238/course/request_url.asp?user_name=j:
User_idisnull,pleasecheckit
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
<styletype= "Text/css" >
<!--
. Input{background-color: #FFFFFF; Border-bottom:black1pxsolid;border-left:black1pxsolid;border-right: Black1pxsolid;border-top:black1pxsolid;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>
<formname= "Course" action= "request_form.asp" method= "POST" >
User_id:<inputtype= "text" name= "user_id" maxlength= "" class= "input" ><br><br>
User_name:<inputtype= "text" name= "user_name" maxlength= "" class= "Input" >
</form>
<br><br>
<ahref= "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
Ifuser_id= "" Then
Response.Write "User_idisnull,pleasecheckit"
Response.End
endif
Ifuser_name= "" Then
Response.Write "User_nameisnull,pleasecheckit"
Response.End
endif

' Print variable
response.writeuser_id& "<br>"
Response.writeuser_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.writerequest.cookies ("Time_now")
%>

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


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

Effect:
①. Error accessing this page when the buffering function of IIS is turned off
A
Reply Object error ' asp0156:80004005 '
Head wrong
/course/response_buffer.asp, Line 3
HTTP headers have been written to the client browser. Any HTTP headers must be modified before the page content is written.
②. When you turn off the buffering function of IIS and remove comments from the first line of the file, the page redirection succeeds
③. When you turn on the buffering function of IIS, page redirection succeeds regardless of whether or not you remove the comments from the first line of the file

3. Server

Definition: You can use different entity functions on the server, such as controlling when the script executes before time arrives. It can also be used to create other objects.

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.