Request| Object Author: scholar
From the beginning of this article, the author starts from the ASP, and analyzes the characteristics and methods of the ASP's six built-in objects and various components in detail.
Before we begin to learn the ASP's built-in objects and components, let us understand some basic concepts, which will be of great help to you in your future study. Take a look at the following table:
A collection of server-side technologies that are delivered by Active server with Windows NT. These technologies provide consistent server-side components, scripting models, and a set of integrated system services for component application management, database access, transactions, and messaging.
Active Server Pages (ASP) runs the server-side scripting environment for ActiveX scripts and ActiveX components on the server. Developers can combine scripts and components to create web-based applications.
ActiveX enables developers to create rich Microsoft technical terminology for interactive components for the world Wide Web. A set of language-independent interoperability technologies that allow software components written in different languages to work together in a networked environment. The key elements of ActiveX are the Component Object Model (COM) and the Distributed Component Object Model (DCOM). These technologies have been licensed by open organizations and have been ported to many platforms.
ADO Active data Object. A set of object-based data access interfaces optimized for data-centric applications based on the Internet. ADO is based on published specifications and is shipped with Microsoft Internet Information Server and Microsoft Visual InterDev.
The name of the DSN data source. Open Database Interface (ODBC) is used to reference the logical name of the driver or other information required to access the data. The name used by an Internet Information Server to connect to an ODBC data source, such as a SQL Server database.
Event: Any action that is responded to by a program produced by a user or ActiveX control. General events include pressing keyboard keys, selecting buttons by using the mouse click, and other mouse actions. Programmers write code that responds to these actions.
Object: In object-oriented programming, a variable consisting of operations and data as a complete entity. Objects are based on a specific model in which the client uses the object's services to access the object's data through an interface of a set of methods or related functions. The client can then call these methods to perform an operation.
ODBC Open Database interface. An application programming interface that allows applications to access data from the standard specifications of existing data sources that are accessed from a variety of cross-platform data.
SQL Structured Query Language structured query Language. Defines and accesses international standards for relational databases.
What is an object? It's not about your partner or girlfriend you're in love with. In object-oriented programming, an object is a variable consisting of operations and data as a complete entity. Objects are based on a specific model in which the client uses the object's services to access the data of the object through an interface of a set of methods or related functions, and the client can then call these methods to perform an operation. ActiveX components are the key to building WEB applications, and components provide the objects that perform tasks in scripts. An ActiveX component is a file that contains code to perform an item or a set of tasks, because the components can perform common tasks so that programmers do not have to create the code to perform those tasks themselves. You can leverage components as scripts and basic building blocks for web-based applications. As long as you know how to access the objects that the component provides, even a novice who writes scripts can write scripts without knowing how the components work. In summary, components enable you to write powerful scripts without learning to program. A component is an executable code contained in a dynamic-link library. dll or executable file. exe. A component can provide one or more objects and the methods and properties of an object. To use the object provided by the component, create an instance of the object and assign the new instance to the variable name. Using the ASP's Server.CreateObject method to create an instance of an object, a variable assignment instruction using a scripting language can be named for an object instance. The following example:
Set db=server.createobject ("ADODB. Connection ")
The variable db here is the object instance that the ASP program creates to access the database.
Active Server Pages provides built-in objects that you can use in scripts. These objects make it easier for users to gather information that is sent through a browser, respond to browsers, and store user information, thereby getting the object developer out of a lot of tedious work. The current ASP version provides a total of six built-in objects, let's go through the examples to learn separately.
One, Request object
You can use the request object to access any information that is delivered based on an HTTP request, including parameters, cookies, and user authentication that are passed from the HTML table using the POST method or the Get method. The Request object enables you to access the binary data that the client sends to the server.
Syntax for Request:
Request[. Collection | properties | methods] (variables)
Here the author will pick some common object syntax to analyze
1, Form
The form collection retrieves the values of the table elements that are sent to the body of the HTTP request by using the form of the POST method.
Grammar
Request.Form (Element) [(index) |. Count]
Parameters
element specifies the name of the table element to retrieve for the collection.
The index optional parameter, which you can use to access one of several values in a parameter. It can be 1 to request.form (parameter). Any integer between Count.
Number of elements in the Count collection
The Form collection is indexed by the name of the parameter in the body of the request. The value of Request.Form (element) is an array of all element values in the request body. by calling Request.Form (element). Count to determine the number of values in the parameter. If the parameter is not associated with more than one value, the count is 1. If the argument is not found, the count is 0. To reference a single value in a TABLE element that has multiple values, you must specify the index value. The Index argument can be from 1 to Request.Form (element). Any number in Count. If you refer to one of several table parameters without specifying the index value, the returned data will be a comma-delimited string.
You can use the Restatement character to display all the data values in the table request. For example, the user fills out a form by specifying several values, as shown in the following figure.
For hobby parameters, you can use the following script to retrieve these values. < html> < head>< title></title>
Clip the above code into a notepad (note that the space after "<" is removed), save it as a form.asp file and run, and the request object can display the elements one at a different basis depending on how you fill in the form or select the element content.
Of course use for ... The next loop can also generate the same output, as follows:
<%
For I = 1 to Request.Form ("hobby"). Count
Response.Write Request.Form ("hobby") (I) & "< br>" Next
%>
2, QueryString
The QueryString collection retrieves the value of a variable in an HTTP query string that is specified by the value of the question mark (?). Such as:
< a href= "Example.asp?string=this is a sample" >string sample&