18-05-2012, 04:08 PM
CREATING AND PROCESSING HTML FORMS
HTML-Forms.pdf (Size: 561.61 KB / Downloads: 131)
How HTML Forms Transmit Data
HTML forms let you create a variety of user interface controls to collect input in a
Web page. Each of the controls typically has a name and a value, where the name is
specified in the HTML and the value comes either from user input or from a default
value in the HTML. The entire form is associated with the URL of a program that
will process the data, and when the user submits the form (usually by pressing a button),
the names and values of the controls are sent to the designated URL as a string
of the form
The FORM Element
HTML forms allow you to create a set of data input elements associated with a particular
URL. Each of these elements is typically given a name in the HTML source code,
and each has a value based on the original HTML or user input. When the form is
submitted, the names and values of all active elements are collected into a string with
= between each name and value and with & between each name/value pair. This
string is then transmitted to the URL designated by the FORM element. The string is
either appended to the URL after a question mark or sent on a separate line after the
HTTP request headers and a blank line, depending on whether GET or POST is used
as the submission method. This section covers the FORM element itself, used primarily
to designate the URL and to choose the submission method. The following sections
cover the various user interface controls that can be used within forms.
ACTION
The ACTION attribute specifies the URL of the server-side program that will
process the FORM data (e.g.,
raiser). If the server-side program is located on the same server from
which the HTML form was obtained, we recommend using a relative URL
instead of an absolute URL for the action. This approach lets you move both
the form and the servlet to a different host without editing either. This is an
important consideration since you typically develop and test on one machine
and then deploy on another. For example,
METHOD
The METHOD attribute specifies how the data will be transmitted to the HTTP
server. When GET is used, the data is appended to the end of the designated
URL after a question mark. For an example, see Section 19.1 (How HTML
Forms Transmit Data). GET is the default and is also the method that is used
when the user types a URL into the address bar or clicks on a hypertext link.
When POST is used, the data is sent on a separate line. Either GET or POST
could be preferable, depending on the situation.