Sideway
output.to from Sideway





Draft for Information Only

Content

Request Object
 Request.Form Collection
   Syntax:
   Parameters:
   Remarks:
  Examples:

Request Object

The main function of Request object is the retrieving of HTTP request variables from the client.

Request.Form Collection

Request.Form Collection retrieves the element values of a form which is sent in the body of HTTP request with a form using the POST method.

Syntax:

Request.Form(element)[(index)|.Count]

 Or in an ASP file. Imply

<% Request.Form(element)[(index)|.Count] %>

Parameters:

element

The parameter "element" is the name of the form element in the form collection to be retrieved. The data type of "element" is string and is enclosed by quotation marks (" ").

index

The optional parameter "index" is the number of the index of a form element with multiple values in the form collection to be retrieved. The data type of "index" is an integer and the range is from 1 to  Request.Form(element).Count

.Count

The parameter "Count" is the optional information of the parameter "element" with delimeter ".". The parameter "Count" is a read-only attribute to return the total number of the available values of the parameter " element".

Remarks:

The HTTP form collection is the string posted to the HTTP request body with a form using the POST method.

Although HTTP form collections are usually generated by a response page output, HTTP form collection are only strings contained in an request headers. The values of HTTP form collection can also be generated by any user. Therefore header data or user input should be encoded or be validated before using.

The Form Collection is indexed by the names of the parameter elements in the request body. With the Request.Form Collection, the value of form element can be retrieved by name.

For element with multiple values, the value of Request.Form(element) will be in form of an array of all values of the element in the Form Collection. And the number of multiple values of the element can be obtained by  Request.Form(element).Count. For single value varible,  Request.Form(element).Count equal to 1. If the variable does not exist,   Request.Form(element).Count equal to 0.

And therefore the multiple values of a variable can be referenced by the parameter "index",  Response.Form(element)(index). and the range of the index is from 1 to  Response.Form(element).Count.

However, if the index is not specified for a multiple values element, the Request.Form(element) will return all values in the form of comma-delimited string.

Besides, if there is no specified element for the Request.Form(), the Request.Form() will return the unparsed Form Collection data. But when post data more than 100KB, the Request.Form cannot be used. And should be rewritten by using the Request.Binary Read method.

Since the multiple values of a element is in the form of an array, the values of the element can be retrieved using a for index loop or a for each element loop.  And for the name of the form element, a for each element loop should be used.

Examples:

  • HTTP form submit

    ASP script command:

    <% ... Request.Form ... %>
    <form action="../../../form.asp" method="post">
    A:<input name="A" value="9" size="4" />  and
    B:<input name="B" value="1" size="4" /> plus <input name="B" value="2" size="4" />
    <input type="SUBMIT" />
    </form>

    HTML web page ouput (Layout):

    A: and B: plus

    HTTP Request:

    ../../../form.asp

    HTTP Request Body:

    A=9&B=1&B=2

    CMD commands: 

    telnet www.output.to 80 (CR)
    Post /form.asp HTTP/1.1 (CR)
    Host: www.output.to (CR)
    Connection: keep-alive (CR)
    Content-Type: application/x-www-form-urlencoded(CR)
    Content-Length: 11(CR)
     (CR)

    (... Response ...)
    HTTP/1.1 100 Continue
    Server: Microsoft-IIS/5.1
    Date: Tue, 31 Jan 2012 15:19:08 GMT
    X-Powered-By: ASP.NET 

    A=9&B=1&B=2

    (... Response ...)

  • With no variable specified in Request.Form

    ASP script command:

    <%= Request.Form %>

    HTTP response output (Buffered):

    A=9&B=1&B=2

    HTML web page ouput:

    A=9&B=1&B=2

  • With variable A specified in Request.Form

    ASP script command:

    <%= Request.Form("A") %>

    HTTP response output (Buffered):

    9

    HTML web page ouput:

    9

  • With variable B specified in Request.Form

    ASP script command:

    <%= Request.QueryString("B") %>

    HTTP response output (Buffered):

    1, 2

    HTML web page ouput:

    1, 2

  • With variable B specified in Request.Form().Count

    ASP script command:

    <%= Request.Form("B").Count %>

    HTTP response output (Buffered):

    2

    HTML web page ouput:

    2

  • Loop for all values in variable B specified in Request.Form() by count

    ASP script command:

    <%
    For i=1 to Request.Form("B").count
    Response.Write Request.Form("B")(i) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    1<br />
    2<br />

    HTML web page ouput:

    1
    2

  • Loop for all values in variable B specified in Request.Form() by item

    ASP script command:

    <%
    For Each item in Request.Form("B")
    Response.Write (item) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    1<br />
    2<br />

    HTML web page ouput:

    1
    2

  • Loop for all form elements in the form by item

    ASP script command:

    <%
    For Each item in Request.Form
    Response.Write (item) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    A<br />
    B<br />

    HTML web page ouput:

    A
    B


©sideway
close

References

  1. Active Server Pages, http://msdn.microsoft.com/en-us/library/aa286483.aspx, updated 20Dec2012
  2. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx, updated 21Dec2012
  3. ASP Best Practices, http://technet.microsoft.com/en-us/library/cc939157.aspx, updated 15Apr2013
  4. ASP Built-in Objects, http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx, updated 20Dec2012
  5. Response Object, http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx, updated 20Dec2012
  6. Request Object, http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx, updated 20Dec2012
  7. Server Object (IIS), http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx, updated 20Dec2012
  8. Application Object (IIS), http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx, updated 20Dec2012
  9. Session Object (IIS), http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx, updated 20Dec2012
  10. ASPError Object, http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx, updated 20Dec2012
  11. ObjectContext Object (IIS), http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx, updated 20Dec2012
  12. Debugging Global.asa Files, http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx, updated 15Apr2013
  13. How to: Debug Global.asa files, http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx, updated 15Apr2013
  14. Calling COM Components from ASP Pages, http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx, updated 15Apr2013
  15. IIS ASP Scripting Reference, http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx, updated 15Apr2013
  16. ASP Keywords, http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx, updated 15Apr2013
  17. Creating Simple ASP Pages, http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx, updated 15Apr2013
  18. Including Files in ASP Applications, http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx, updated 15Apr2013
  19. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx, updated 15Apr2013
  20. FileSystemObject Object, http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx, updated 14Mayr2013
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, ADO Object Model, updated 15Apr2013
  22. ADO Fundamentals, http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx, updated 14Mayr2013
close

ID: 120200018 Last Updated: 2/7/2012 Revision: 0 Ref:

IMAGE

Home (5)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1097)

English (336)

Reference (66)

Computer

Hardware (149)

Software

Application (187)

Digitization (24)

Numeric (19)

Programming

Web (704)new

CSS (SC)

ASP.NET (SC)

Regular Expression (SC)

HTML

Knowledge Base

Common Color (SC)

Html Entity (Unicode) (SC)

Html 401 Special (SC)

OS (389)

MS Windows

Windows10 (SC)

.NET Framework (SC)

DeskTop (7)

Knowledge

Mathematics

Formulas (8)

Algebra (20)

Number Theory (206)

Trigonometry (18)

Geometry (18)

Calculus (67)

Complex Analysis (21)

Engineering

Tables (8)

Mechanical

Mechanics (1)

Rigid Bodies

Statics (92)

Dynamics (37)

Fluid (5)

Fluid Kinematics (5)

Control

Process Control (1)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)

Latest Updated Links

Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 10 Feb 2019