In HTTP servlets for Java I want to submit a form. What is the recommended way
of carrying the values from the input fields? Is it using hidden fields
and get them through request.getParameter(...)
or with request.getAttribute(...)
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
All form submitted can ONLY be accessed through
getParameter(...)
.getAttribute()
is meant for transferring request scoped data across servlet/jsp within the context of a single request on server side.All the form data will be sent as request parameters with the input field name as parameter name and the input field value as parameter value.
E.g.
With inside
doPost()
method:You don't need to use JavaScript to transfer them to other hidden fields or something nonsensicial, unless you want to pass additional data which the enduser don't need to enter itself.
The request attributes are to be used for the other way round; for passing the results from the servlet to the JSP file which should in turn present them along all the HTML.
See also: