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.
Thanks in advance,
If a single form, are you assigning the same name for each element in the rows? If so, all the rows are being submitted but you may bt be accessing them correctly to retrieve all the values.
More info is needed to answer the above questions.
For Row 1 LName FName EmpID
For Row 2 LName FName EmpID
For Row 3 LName FName EmpID
I know that there should be a number appended to the names when I retrieve them, but I don't know how to access them in the servlet when the form is submitted.
Many 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.