Request| object ASP Built-in object request and Respones
The web originates from static text, and many sites are now almost in this way. The disadvantage of static text is that it is difficult to maintain (the number of files), query difficult, modify difficult. Although you can use FrontPage to manage your site, this is just one way to do it. Now, many sites will be in the background to adopt a database, dynamically generated hypertext. To change the style, you only need to modify several files, to change the content, only the database to operate, and easy to maintain consistency, while for Full-text search applications such as query, the superiority of this approach is more prominent. (often said "dynamic" also includes the dynamic display of pictures, such as animated GIF, Java applet, etc., this article refers to the dynamic of the data)
Common Gateway Interface CGI (Common Gateway Interface) and network Server Application interface ISAPI (Internet Server application Programming Interface) and other related technologies, So that we can easily communicate with the Web server, so as some counters, message board, and other CGI programs appear in succession.
But these CGI programs have a big disadvantage is that CGI (can be VB, Java, Perl, C, or Dephi) and HTML can only write separately, separate operation, to combine the two is not easy, which leads to maintenance and writing are very difficult. As a result, some vendors later introduced their own script language to enhance the functionality of web development. Netscape introduced JavaScript (for client side and for server end), and Microsoft introduced VBScript and ASP (ASP syntax similar to VB syntax), but also for server-side and client program writing. For professional developers, the most important point of the client program is versatility, while the server side emphasizes functionality and efficiency. JavaScript is certainly the best for the development of client-side programs, because today both major browsers IE and Netscape claim to support the standard, while VBScript is only supported by IE. But what bothers us is that some of the JavaScript tags, ie or some versions of IE are not necessarily supported, which will cause us to have to move part of the program to the server to execute, because the server-side program will explain the generation of HTML (or ActiveX) text, and then sent to the client, Therefore, there is no compatibility problem.
Livewire (the JavaScript for server-side compiler), like the ASP, is the manuscript language (the manuscript is the same as the client side of JavaScript, can be nested inside the HTML text, just tag to indicate that the server executes the program segment) , an object-oriented language similar to C + +. Livewire file suffix name or html,asp file suffix name is ASP, because the ASP's file when the client read it, the server to explain, and livewire files must be compiled in advance (after each modification, to recompile). The ASP has a corresponding auxiliary development tool (InterDev) that can generate some controls on its behalf. Of course, these are not important, whether you are using Netscape Web Server or Microsoft IIS. In general, however, because IIS is bundled with NT, IIS users tend to be more biased.
Since Netscape's launch of Livewire and Microsoft's Active Server page, it has been easy and much easier for programmers to write online programs. But the language of the script class has a common disadvantage, that is, because it is interpreted and executed, it is not too fast. Recently, Microsoft proposed to adopt a three-tier model, the middle tier can not use ASP, and directly using VB6.0 generated ActiveX control, because it is compiled to execute, it is faster, but this is something.
First, the basic object of ASP
ASP (Active Server Page) is an object-oriented programming language similar to VB. Rather than dwell on some basic concepts such as objects, this is a straightforward introduction to their language features, so that developers can skillfully modify and compile ASP programs (because many people simply use development tools such as InterDev to generate ASP programs).
First, the ASP program's archive name must be "ASP", and secondly, in the ASP program, server-side script should be placed in the middle of the string, for example. If you want to invoke another ASP file in an ASP file, add the following statement to the ASP: <! --#INCLUDE virtual| File= "***.asp"--this is somewhat like the #include in C language. The virtual file path is represented by dummy, and file represents the true file path.
The ASP has five main built-in objects: Request, Response, Server, Session, application, which are illustrated separately below.
1. Request
ASPs still follow the popular method of exchanging data with the client's form. The request object built in ASP has five methods for obtaining client data (querystring/form/cookies/servervariables/clientcertificate).
Syntax: Request. Method Name ("Parameters") |request ("parameters")
If you use the latter, the system will automatically select the appropriate method.
Form
Again, some of the properties of form are highlighted:
MIME form of enctype= data transfer
The way method= transmits information get/post
Onrest= Press the rest key to invoke the program
Onsubmit= Press the Sumit key to invoke the program
Target= the frame window of output content >
There are three ways to send information using form: The form in the HTML page transmits information to other ASPs, and the form in the ASP transmits information to the other asp;asp.
Syntax: request.form (parameters) [(index)]
Where the parameter represents the name of the element in the form, and the index represents the ordinal number of the same name element.
Cases:
You can iterate through the element with the name user, where count is the system property of the form, which computes the number of elements with the same name, and zero if the element does not exist. If you do not indicate that you want to read the first few elements of the same name, the system reads the values of all the identically named elements and uses the "," interval.
Example: Request.Form ("user") =ABC,BCD,CDE
In addition to using form to transmit data, you can also connect to "?" after hyperlinks. The way in which information is transmitted, such as: At this time, the transmitted information can be read by Request.QueryString ("user"), and if there are multiple parameters with duplicate names, such as:, the first time
Resquest.querystring ("user") =abc, second
Resquest.querystring ("user") =BCD, third time
Resquest.querystring ("user") =cde.
3, ServerVariables
Syntax: ServerVariables (parameter name)
We know that the Web/browse transport protocol is a http,http header that will have some client information, such as
Customer IP address, browser language system, and so on. This can be done by Request.ServerVariables ("* *") to obtain relevant information, such as Request.ServerVariables ("Accept_language") to obtain the client browser language family. Other system parameters are shown in the following table:
The machine name or IP address of the server_name server.
Server_port server is running port number
Request_method the method of issuing the request (Get/post/head
Script_name the path to which the program is invoked, such as: cgi-bin/a.pl.
Remote_host the name of the remote machine (client) that issued request requests.
REMOTE_ADDR the IP address of the remote machine (client) where the request is issued.
Remote_ident the name of the user who issued the request (in the case of a dial-up connection, the UserID), which is valid when NCSA IdentityCheck is enabled and the client machine supports RFC 931.
Content_Type the MIME type of the data, such as: "text/html".
Http_accept the list of MIME types that the client can accept.
The browser type of the Http_user_agent client issue request.
Http_referer the text URL that the client refers to before reading the CGI program.
4. Cookies
On the client side, Cookies record a lot of information about the client browser, we can obtain its value by Request.Cookies ("name") command, or we can record some information on the client by Response.Cookies ("name") = "value" to control the visitor. The method for setting multiple Cookies is Response.Cookies ("name") ("name") = "value".
5, Cache
We can set up a browser to extract the pages that have been visited from the cache, and similar settings can be made in the ASP program. Where Response.Clear is the memory that empties the client. The Response.buffer=true setting can read data from the cache (false by default).
6, ClientCertificate
ClientCertificate is used to obtain the authentication information of the client browser (conforming to the X.509 standard), but the client browser must support the SSL3.0 or PCT1 protocol. There are two steps to take, the first step: Web server must start the Client authentication option; The second step is to set up the browser appropriately so that the method takes effect, otherwise, returns the empty value.
2, Response
When you want to transfer data from the server to the client, you can use the following method:
1) Response.Write Direct output information, such as Response.Write "".
2 Response.Redirect boot the client to another URL location, such as Response.Redirect "Http://zyr.yeah.net", but here's a question to note that the statement must be executed before the tag, This means that the server does not have to send an HTML text header to the client before it is executed, or a transmission error message appears.
3 Response.ContentType Control the output of the file type, the server to the client packet type can be text/html text or gif/jpeg graphics files, so each transmission before we must inform the client will be transmitted file types, The "text/html" type is generally by default.
4 Response.Cookies is used to set the value of Cookies, the syntax is: response.cookies (variable name) [(Key) | Property]= write information. (The use of key is described earlier, not described here) the cookie system defaults to five properties, including expires (time), domain (name), path (path), secure (security), HasKeys (To determine if there are other cookies under the cookie text).
5) Response.Buffer is used to determine whether the information is transferred to the buffer. Because sometimes we want to send some of the intermediate information to the buffer and continue working. When all processing work is completed, the information is exported to the client. But when the flush or End method is invoked during processing, the contents of the buffer are output.
Other properties of response:
Expires: Sets the length of time the Web page remains in the client browser.
ExpiresAbsolute: Sets the date and time that the Web page remains in the client browser.
Other ways to Response:
AddHeader: Sets the HTTP header for the HTML file.
AppendToLog: Adds a string at the end of the Web server record file.
Clear: Clears the HTML output data in the buffer.
End: Stop processing the ASP file and return to the state at that time.
Flush: Immediately send out the HTML data of the buffer.
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.