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(...)?
In HTTP servlets for Java I want to submit a form. What is the
Share
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: