Hey there, I have a JSP page that displays data in a table from a database. The rows are created based on the results from the database. Basically there are some textfields that allow a user to enter in stuff, when they click on the search button a servlet builds a prepared statement based on the parameters in the textfields. The database returns a result and this is displayed on the JSP page. I want to save the results in a new table and allow the user to search for new data. Then I will submit this new table which will be the result of multiple queries. My problem is that I don't know how to get the results of the first table into my servlet. I know that there is an elements array of all the form fields in my form on my JSP page, but when I submit my form to the servlet, I only see the first row of data in the table. Is there some DOM thing I'm missing? How do I get the elements array into the servlet? Do I have to build a document? I realize some of the things here might be complex and that submitting a table from a JSP page that has multiple rows with elements that have the same name, might be rather basic, but I would really appreciate the help.
To retrieve multiple elements that share the same name use request.getParameterValues().
Joined: Oct 24, 2000
Yeah that is working, providing that each <td> cell has an input field(like a textfield) in it. The <td> cells that don't have an input field don't show up as parameters in the servlet and I don't get the data they contain. Thanks for your advice.
Originally posted by Jay Brass: Yeah that is working, providing that each <td> cell has an input field(like a textfield) in it. The <td> cells that don't have an input field don't show up as parameters in the servlet and I don't get the data they contain. Thanks for your advice.
That's correct, a table is not a form element. You will need to put a valid form element (such as a text input field) in each cell if you want the values to be submitted with the form.