ASP Getting Started tutorials-request Objects Overview

Source: Internet
Author: User

The request object retrieves the values that the client browser passes to the server during the HTTP request. That is, it is used to interact with the client, collect client information or server-side environment variables, and then send the collected information to server-side or other ASP pages.

A collection of Request objects

The Request object has a total of 5 collections, as shown in the following table:

Collection name Description
ClientCertificate When a client accesses a page or other resource, the numeric collection of all fields or entries for the client certificate that is used to identify the server, and each member is read-only. (Used to retrieve the field values stored in the client certificate sent to the HTTP request)
Cookies According to the user's request, a collection of all Cookier values issued by the user system that are valid only for the corresponding domain, and each member is read-only. (used to retrieve the value of a cookie sent in an HTTP request.) )
Form

When the property value of method is post, all collections of the values of the HTML control cells in the <form> section that are submitted for the request are set, and each member is read-only. (used to retrieve the value of a form element in the body of the HTTP request.) )

QueryString When form information is sent through get, the server-side or another ASP page is received using the QueryString method. (used to retrieve the value of a variable in an HTTP query string.) )
Severvariables The HTTP header value issued with the client request, which is a collection of values for several environment variables of the Web server, and each member is read-only. (used to retrieve the value of a predetermined environment variable.) )

Note: In these collections, the most commonly used are form, Cookies, and querystuing collections.

Ii. attributes of the request object

TotalBytes is the only property of the request object that provides information about the number of bytes requested by the user, and returns the number of bytes of request information sent by the client. The value of the request information, rather than its length, is often a concern in use, so this property is rarely used for ASP pages.

Iii. method of Request object

BinaryRead is the only method of the request object that allows access to the full contents of the request information that is passed to the server from the user page <FORM> segment, and the Acer syntax format is as follows:

Requset.BinaryRead(count)

Description: Count indicates the number of bytes of data that were obtained from the customer request when the data was sent to the server as part of a POST request. The method returns a Variant array (or SAFEARRAY). If the ASP code already references the Request.Form collection, this method is no longer available. Similarly, if you use the BinaryRead method, you can no longer access the Request.Form collection.

Iv. use of the Request object

In ASP, when a page is requested or a form is passed, the request object provides the script with all the information provided by the client browser. The syntax format is:

Request.[ 集合 | 属性 | 方法 ] (变量)

ASP's interaction with forms

In Dynamic Web page design, the user input information is often accepted by the table forms. The syntax format of the form tags is as follows:

<Form method=传送方式 action="URL">...</FORM>

Where: "URL" sets the relative or absolute position of the handler. "Transfer Mode" is used to indicate how the interactive form is transmitted, with post and get two kinds.

There are usually three ways to use forms to transfer information:

1 An ASP file that transmits information from a form in an HTML Web page to the processing of that information.

2 from the ASP file in the form of the transfer of information by its own processing.

3 The form of the ASP file to transfer information to another ASP file to handle.

Example 1: Enter and submit information using a form in an HTML Web page named 1.htm. The request object in the server-side form handler named 1.asp reads the browser-side data and returns the appropriate information.

The 1.htm Web page code is as follows:


<body>
<form action="8-1.asp" Method="post">
姓名:<input tyjpe="Text" name="姓名" size=8><br><p>
性别:男<input type="Radio" name="性别" value="男" Checked>
女<input type="Radio" name="性别" value="女"><p>
<input type="Submit" value="提交">
<input type="Reset" value="重写">
</form>
</body>

The 1.asp Web page code is as follows:


<Body>
<p align="center">欢迎您登录本站点<p>
<%
Response.write"您是:" & Request.form("姓名")
if Request.form("性别")="男" then
Response.write"。是一位帅男。"
else
Response.write"。是一位亮妹。"
end if
%>
<p><a href="1.htm">返回上一页</a></P>
</Body>

Instance 2: We can combine the top two pages into a single Web page, and the information about the table conveys is handled by itself. The code is as follows:


<body>

<center>
<%
xm=Request.form("姓名")
xb=Request.form("性别")
if xm<>"" then
Response.write"<p>欢迎登录本站<br>"
Response.write"您的大名是" & xm &"。"
if xb="男" then
Response.write".是一位帅男。"
else
Response.write"。是一位亮妹。"
end if
Response.write"<P><a href='4-3-1.asp' target='txtFrame'>返回上一页</a>"
Response.end
end if
%>
请输入
<form Action="2.asp" method=post>
姓名:<input type="text" Name="姓名" size=8>
性别:男<input type="Radio" Name="性别" value="男" checked>
女<input type="Radio" Name="性别" value="女"><p>
<input type="Submit" value="提交">
<input type="Reset" value="重写">
</form>
</center>
</body>

See the full set of ASP Getting started tutorials

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.