ASP built-in object Request

xiaoxiao2021-03-06  56

can use

REQUEST

Object Access any

HTTP

Request all the information passed, including

HTML

Form

POST

Method or

Get

The parameters transmitted by the method,

cookie

And user authentication.

REQUEST

Object allows you to access binary data sent to the server to the server.

Request's grammar:

Request [. Collection | Properties | Method] (Variable)

Here, the author will analyze some commonly used object syntax

1, FORM

The Form Collection Retrieves the value of the table element in the HTTP request body by using the form of the POST method.

grammar

Request.form (ELEMENT) | .count]

Parameter ELEMENT Specifies the name of the table element to be retrieved.

Index optional parameters, using this parameter can access one of a plurality of values ​​in a parameter. It can be any integer between 1 to Request.form (Parameter) .count.

Number of elements in count collection

The Form set is indexed according to the name of the parameter in the text. The value of Request.Form (Element) is an array requesting all ELEMENT values ​​in the body. Determine the number of values ​​in the parameter by calling Request.form (Element) .count. If the parameter is not associated with multiple values, the count is 1. If the parameters are not found, the count is 0. To reference a single value in a table element with multiple values, you must specify an index value. The index parameter can be any number from 1 to REQUEST.FORM (Element) .count. If one of the plurality of table parameters is referenced, the index value is not specified, the returned data will be a comma-separated string.

You can use a rearray to display all data values ​​in the table request. For example, the user fills in the form by specifying several values, see the left.

For Hobby parameters, you can retrieve these values ​​using the following scripts. </ title> </ head> <body> <p> Please fill in your hobby </ p> <form method = "post" action = "form.asp"> <p> <input type = "text" name = "hobby" size = "20"> <br> <input type = "checkbox" name = "hobby" value = "football"> football <input type = "checkbox" name = " Hobby "Value =" Table Tennis "> Table Tennis </ P> <P> <Input Type =" Submit "Value =" Send "Name =" B1 "> <input type =" reset "value =" Refill "Name = "B2"> </ p> </ form> <% for each i in request.form ("hobby") response.write I & "<br>" Next%> </ body> </ html></p> <p>Scrapped the above code to the Notepad (Note Remove the spaces behind "<"), save to the form.asp file and run, the Request object can be displayed according to your different elements in the form of the Form. . Of course, the same output can be generated using the for ... next loop, as shown below:</p> <p><%</p> <p>For i = 1 to Request.form ("hobby"). Count</p> <p>Response.write Request.form ("Hobby") (i) & "<br>" Next</p> <p>%></p> <p>2, QueryString</p> <p>QueryString Set Retrieves the value of the variable in the HTTP query string, the HTTP query string is specified by the value after the question mark (?). Such as:</p> <p><A href = "eXample.asp? String = this is a name"> String Sample </ a></p> <p>Generate variable name strings for "this is a sample". You can also generate a query string by sending a table or typing a query in an address box in its browser.</p> <p>grammar</p> <p>Request.QueryString (variable) [(index) | .count]</p> <p>QueryString Collection allows you to retrieve query_string variables in a name. The value of the request.QueryString is an array of values ​​that appear in all parameters in query_string. You can determine how many values ​​have parameters by calling request.QueryString (parameter) .count.</p> <p>We can also use queryString to achieve the same features as the previous example. Just replace the Request.form section as follows:</p> <p><%</p> <p>For Each I in Request.QueryString ("Hobby")</p> <p>Response.write I & "<br>"</p> <p>NEXT</p> <p>%></p> <p>3, cookies</p> <p>What is a cookie? Cookie is actually a label, when you visit a web site that needs to uniquely identify your site, it will leave a tag on your hard disk, the next time you visit the same site, the site page Will find this tag. Each Web site has its own tag, and the content of the mark can be read at any time, but can only be done by the page of the site. The cookies of each site are in different files in all the cookies of all other sites (you can find them in the cookie folder in Windows's directory). A cookie is a unique identity of the customer's tag, and the cookie can contain information shared by all pages of a web site between a dialog or several dialogues, using cookies to exchange information between the pages. The Cookies collection provided by the Request allows the user to retrieve the value of the cookie sent in the HTTP request. This feature is often used in an ASP program that requires authentication customer passwords and electronic bulletin boards, web chat rooms.</p> <p>grammar</p> <p>Request.cookies (cookie) [(key) | .attribute]</p> <p>parameter</p> <p>Cookie Specifies the cookie to search on its value.</p> <p>Key Optional parameters for retrieving the value of the sub-key from the Cookie dictionary.</p> <p>AttribE specifies information about cookie itself. Such as: Haskeys read-only, specify whether cookies contains keywords.</p> <p>You can access the sub-keyword of the cookie dictionary by including a KEY value. If you do not specify a key when accessing the Cookie dictionary, all keywords are returned as a single query string. For example, if MyCookie has two keywords, first, and second, no keywords are specified when calling request.cookies, then the following string will be returned. First = firstKeyValue & Second = SecondKeyValue</p> <p>If the client browser sends two favorite cookies, then Request.cookie will return one of the deeper path structure. For example, if there are two favorite cookies, but one of the path properties is / WWW / and the other is / www / home /, the client browser simultaneously sends two cookies to / www / home / directory Then, Request.cookie will only return the second cookie.</p> <p>To determine if a cookie is not a cookie dictionary (Cookie has a keyword), you can use the following scripts.</p> <p><% = Request.cookies ("MyCookie"). Haskeys%></p> <p>If MyCookie is a cookie dictionary, the previous assignment is True. Otherwise, for False. Let's take a look at a cookie application instance:</p> <p><%</p> <p>Nickname = Request.form ("Nick") response.cookies ("nick") = nickname</p> <p>'Write the user name into the cookie with the Response object</p> <p>Response.write "Welcome" & Request.Cookies ("NICK") & "Guangping Station!"</p> <p>%></p> <p><html> <head> <meta http-equiv = "content-type" content = "text / html; charSet = GB2312"></p> <p><title> cookie </ title></p> <p><meta name = "generator" content = "Microsoft FrontPage 3.0"> </ head></p> <p><body></p> <p><form method = "post" Action = "cookie.asp"></p> <p><p> <input type = "text" Name = "nick" size = "20"></p> <p><Input Type = "Submit" value = "Send" Name = "B1"> <input type = "reset" value = "Refill" Name = "B2"> </ p> </ form></p> <p></ body> </ html></p> <p>This is actually a technique that is commonly used in the web-based BBS or CHAT ASP program, which saves the user in the name of the start page in cookie, so the latter program can easily call the user's Nick .</p> <p>4, ServerVariables</p> <p>Everyone knows that the transfer protocol used when browsing the webpage in the browser is http, and some client information will be recorded in the HTTP title file, such as: the client's IP address, etc., sometimes the server side needs to be based on different client information. Make different reflections, this time you need to get the information you need with the ServerVariables collection.</p> <p>grammar</p> <p>Request.ServerVariables (server environment variable)</p> <p>Since the server environment variables are large, the author only lists some common variables in the table below:</p> <p>All HTTP header files sent by the all_http client.</p> <p>The Content_length client issues the length of content.</p> <p>Content_type content data type. Such as: "Text / HTML". Use with additional information, such as HTTP query GET, POST, and PUT.</p> <p>Local_addr Returns the server address that accepts the request. This variable is very important if you look for the address used by the request for multiple IP addresses.</p> <p>Logon_user user logs in to the account of Windows NT.</p> <p>Query_String Query the information after Question mark (?) In the HTTP request.</p> <p>Remote_addr issues the IP address of the Remote Host (Client).</p> <p>Remote_host issues a request for the host (Client) name. If the server doesn't have this information, it will set an empty Mote_Addr variable.</p> <p>Request_method This method is used to make a request. Equivalent to GET, HEAD, POST, etc. used for HTTP.</p> <p>Server_name appears in the server host name, DNS name, or IP address in the self-reference URL.</p> <p>Server_port sends the port number of the request.</p> <p>We can print out all server environment variables using the following scripts.</p> <p><Table></p> <p><TR> <TD> <B> Server Variable </ b> </ td> <td> <b> value </ b> </ td> </ tr> <% for each name in request.servervariables%></p> <p><TR> <TD> <% = Name%> </ TD> <TD> <% = Request.ServerVariables (Name)%> </ TD> </ TR> </ table></p> <p><% Next%></p> <p>Today we learn in detail.</p> <p>ASP</p> <p>Built-in object</p> <p>REQUEST</p> <p>Object, this is also</p> <p>ASP</p> <p>The most frequent objects are used in the program, I hope everyone will practice much after class.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-118297.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="118297" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'e8NWuulrLfOOkvZIpL38Zc9j4wz6Wp0xxtkUF0Edez1xylARskXeP6D5xmhBr42TPv_2Ftp8I6VtOFMhLGvNGJig_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>