ASP built -in object Request and Respones
Web originated from static text, and now many sites still use this method. The disadvantage of static text is to maintain difficulty (large number of files), inquiries, and modification difficulties. Although FrontPage can be managed by the site, this is just one of the methods. Now, many sites will adopt databases in the background to dynamically generate super text. In this way, you need to change the style, just modify a few files; to change the content, you only need to operate the database, and it is easy to maintain consistency. For full -text retrieval and other query applications, the superiority of this method is more prominent. (The "dynamic" often includes the dynamic display of the picture, such as dynamic GIF, Java Applet, etc., the dynamicity of the data referred to in this article)
GM CGI (Common Gateway Interface) and the Internet server application interface IsaPi (Internet Server Application Programming Interface) and other related technologies appear, enabling us to easily communicate with Web Server, thereby like some counter, message versions and other C. GI The program appeared and became windy.
But these CGI programs have a big disadvantage, that is, CGI (which can be written and operated separately by HTML (can be written with VB, Java, Perl, C, or DEPHI, etc.) and HTML. As a result, maintenance and writing are quite difficult. Therefore, some manufacturers later launched their own Script language to enhance the function of web development. Among them, NetScape launched two types of JavaScript (for Client and for Server); Microsoft launched two types of VBScript and ASP (similar to VB syntax), which is also used for writing of server and client programs. For professional developers, the most important point of client programs is universality, while server -side emphasizes function and efficiency. For the development of the client program, JavaScript is undoubtedly the best, because today's two mainstream browser IE and NetScape all claim to support the standard; VBScript can only support IE. But what makes us distressed is that some JavaScript marks, some versions of IE or IE do not necessarily support it, which will cause us to move some programs to the server to execute, because the program side -side program will first explain the generation of generation and generate HTML (or ActiveX) text, and then send it to the client, so there is no compatibility problem.
Like (compiler on the JavaScript for Server) is the same as ASP. It is some manuscript language (manuscript refers to the class segment of the client -like javascript in the HTML text, only the marking is indicated by the label) , That is, the object -oriented language similar to C/C ++. LiveWire's file suffix name is HTML, and the ASP file suffix name is ASP, because the ASP file is explained when the customer reads it, and the LiveWire file must be pre -compiled (after each modification, it is all modified, it is all modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified, it is modified. Re -compilation). ASP has the corresponding auxiliary development tools (INTERDEV), which can be generated to generate some controls. Of course, these are not important. The key is whether you use the NetScape Web Server or Microsoft's IIS. But in general, because IIS is tied to NT, users with IIS will be more.
Since NetScape has launched LiveWire and Microsoft to launch Active Server Page, it is much easier to write online programs for programmers. But this script class language has a common disadvantage, that is, because it is explained, it will not be too fast. Recently, Microsoft recommends using a three -layer model. The intermediate layer can use the ActiveX control directly from VB6.0 without ASP. Because it is compiled, it is fast, but this is the later words.
1. The basic object of ASP
ASP (Active Server Page) is an object -oriented language similar to VB. Here I do not want to detailed some basic concepts such as objects, but directly introduce their language characteristics so that developers can modify and prepare ASP programs proficiently (because many people just use the development tools such as InterDev to generate ASP programs)) ASP programs)) Essence
First of all, the archive name of the ASP program must be "ASP". Second, in the ASP program, the Script of the server should be placed in the middle of the string, for example. If you want to call another ASP file in one ASP file, you can add the following statement to the ASP: <! - #include virtual | file = ***. ASP-> #Include. Among them, Virtual represents the virtual file path, and file represents the real file path.
ASP has five main built -in objects: Request, Response, Server, Session, Application, and will be explained separately below.
1. Request
ASP still follows the popular and uses client's Form for data exchange. ASP's built -in Request object has five methods for obtaining client data (QueryString/Form/Cookies/ServerVariables/ClientCertificate).
Grammar: Request. Method name (parameter) | request (parameter)
If the latter is used, the system will automatically select the corresponding method.
form
Here we re -emphasize some attributes of Form:
enableype = MIME form of data transmission
method = transmitting data method get/post
Onrest = Press the program that the REST key calls
onsubmit = Press the Sumit key call program
Target = Frame window of the output content>
There are generally three ways to transmit information using Form: to other ASPs from Form on the HTML webpage; to another ASP from Form information in ASP; transmit information in the information in ASP to itself.
Grammar: request.form (parameter) [(index)]
The parameters represent the name of the element in Form, and the index represents the sequence number of the same name element.
example:
The element of the name of the name of the name can be read, where the count is the system attribute of Form to calculate the number of the same name elements. If the element does not exist, its value is zero. If you do not indicate the number of the same name elements, the system will read the values of all the elements of the same name and use "," as the interval.
Example: Request.form (user) = ABC, BCD, CDE
2. Querystring
Grammar: Request.querystring (parameter) [(index)]
In addition to transmitting data with FORM, you can also transmit information by connecting "?" After the hyperlink. , Such as:, then the first time
resquest.querystring (user) = ABC, the second time
resquest.querystring (user) = BCD, the third time
resquest.querystring (user) = CDE.
3. Servervariables
Grammar: ServerVariables (parameter name)
We know that the transmission protocol of Web/Browse is HTTP, and the header of HTTP will have some client information, such as
Customer IP address, browser language system, etc. At this time, you can obtain relevant information through Request.servervariables (***), such as Request.servervariables (Accept_language) to obtain the client browser's language system. See other system parameters below:
Server_name server machine name or IP address.
Server_port server is running
Request_Method to emit the REQUEST method (get/post/head
The script_name program is called by: CGI-BIN/A.PL.
Remote_host's name (client) named the remote machine (client) requested by Request.
Remote_addr emits the IP address of the remote machine (client) requested by Request.
Remote_IDENT emits the user name of Request (such as dial -up online, then the user ID). When the NCSA IdentityCheck is enabled, and the Client machine supports RFC 931, the variable is valid.
The MIME type of Content_type data, such as "Text/HTML".
HTTP_ACCEPT Client acceptable MIME type list.
http_user_agent Client emit a request browser type.
Http_referr before reading the CGI program, client refers to the text URL.
4. cookies
On the client, Cookies records a lot of information from the client browser. We can obtain its value through the request.cookies (name) command, or you can record some information on the client through response.cookies to control Visitors. The method of setting multiple cookies is response.cookies (name) = value.
5. Cache
We can set information about the page that I have visited from the Cache on the browser. Similarly, similar settings can be performed in the ASP program. The Response.clear is the memory of the client. Response.buffer = True settings can read data from cache (default is false).
6. Clientcertification
Clientcertification is used to obtain the identity confirmation information of the client browser (complies with the X.509 standard), but the client browser must support the SSL3.0 or PCT1 protocol. Two steps are required. The first step: Web Server must start user -end authentication options; Step 2: Corresponding to the client browser, so that this method will take effect, otherwise, the EMPTY value is passed back.
2. Response
When transmitting data from the server to the client, you can pass the following method:
1) Response.write directly output information, such as response.write.
2) Response.redirect guide the client to another URL position, such as response.redirect http://zyr.yeah.net, but there is a problem here to pay attention to it, that is, the statement must be executed in front of the mark, which means It is executed before the server did not send the HTML text newspaper at the server, otherwise the transmission error message will occur.
3) Response.ContentType controls the file type of the output. The data packet type given to the client to the client can be a Text/HTML text or a GIF/JPEG graphics file, so before each transmission, we must tell the client to be transmitted. File type, generally the "Text/HTML" type by default.
4) Response.cookies is used to set the value of cookies. The syntax is: response.cookies (variable name) [(key) | attribute] = written information written. (Key's usage has been explained earlier, here is not described here) Cookies system has five attributes by default, including Expires, Domain (domain name), PATH (path), secure (security), haskeys (judge whether under cookies are repaired There are other cookies text).
5) Response.buffer is used to determine whether the information is transmitted to the buffer. Because sometimes we want to send some intermediate information to the buffer and continue to work. When all processing work is completed, the information is exported to the client. However, when the Flush or END method is called during the processing process, the buffer content will be output.
Other attributes of response:
Expires: Set the time length of the webpage at the client browser.
Expiresabsolute: Set the date and time of the web page retained at the client browser.
Other ways of response:
addheader: Set the HTTP header of the HTML file.
APPENDTOLOG: Add a string at the end of the Web Server recorded file.
Clear: Clear HTML output data in the buffer.
END: Stop processing ASP files and return to the state at the time.
Flush: Immediately send out the HTML information of the buffer.