<FORM>
tags work.
In particular, there are a number of quirky behaviors that should be noted. When in doubt, you can verify form behavior in various browsers. Since these quirks are often related to browser implementations, and not to the HTML specfication itself, these quirks may change over time.
<SELECT>
control, browsers will automatically submit the first <OPTION>
appearing in the body of a <SELECT>
.
As a workaround, it's often useful to ensure that the first <OPTION>
is a blank value, instead of a 'real' one.
Reminder: if a form includes a file upload control, then it must have :
method='POST'
enctype='multipart/form-data'
Reminder: the Servlet API 2.5 has poor support for file upload requests.
As soon as a form includes a file upload control, the format of the underlying request is completely changed.
In particular, if no special measures are taken, none of the form's data will be available from request.getParameter(String)
; this
applies to all of the form's data, both file upload controls and regular controls.
Tools such as Apache Commons FileUpload are often used to handle such forms. Also note that support for file upload requests has been added to version 3.0 of the Servlet Specification.
Submit
control, whose value
attribute is used both for its visual appearance and for its submitted value.
This is a problem in multilingual applications where forms have more than one submit button (further discussion).
readonly
and disabled
attributes are distinct, and have different behavior.
The most important distinction is that readonly items are submitted, while disabled items are not.
When rendering reports or listings that include boolean values, it is tempting to use a disabled checkbox. However, some feel that such disabled checkboxes don't have a very pleasing appearance. One alternative is to use an image instead of a checkbox control, to present the boolean value. (One might even use an image of a checkbox.)
Submit
button.
However, forms can often be submitted just by hitting the 'Enter'
key.
This behavior is commonly used for web site search boxes.
Be careful that the server can handle both styles of submission - Enter
key and Submit
button.
<TEXTAREA>
controls.
The wrap
attribute can often be added to a TEXTAREA
to define a desired policy for new line characters.
Its values are :
wrap=(hard|soft)
method='POST'
is highly recommended.
If an operation has no side-effect (a list or search operation, for example), then method='GET'
is highly recommended.