posted 20 years ago
Hi Gautam,
Am I right in thinking you have something like the following?:
You want to know how your second JSP will know which row in the table was selected, i.e. which button was pressed, to allow you to perform the required action on the appropriate data.
Now, you populated that table from a set of data, didn't you? Maybe a SQL ResultSet or a List or array, etc. If you put that data object in the session context you can just access it again using the row index of the selected button. You can append the row index to the name of each button and then use getParameterMap() in your second JSP and iterate over the Map's key set to find the appropriate parameter name. An alternative is to use JavaScript to copy the values from the selected row to a hidden form for submission, but that's a bit messy. Or you could copy the seleced row index to a hidden form field with JavaScript. Actually the more I write the more I like Dicky's solution!
Dicky's solution is an alternative but something inside me balks at the idea of having a separate form for every row of a table (I don't actually think it's valid HTML). The way the solution works is that your second JSP will only receive, as request parameters, the fields from the selected row, submitted via the hidden form fields.
At least that gives you some options. Perhaps someone else can offer a better solution?
Jules