| Author |
table element repeats for multiple rows in JSP
|
Poonam Dhatavkar
Greenhorn
Joined: Jan 11, 2013
Posts: 19
|
|
I am implementing 'Search' operation on database using jsp and displaying results in html table.
On jsp page, user 1st enter Column value like id/name and the entire row related to that input should display for further queries like update/delete.
All working fine when displaying one search result/row, bt when there are more than 2 rows to display, it repeats the table display with table head like
--------------
| id |name|
---------------
| 2 | abc |
--------------
| id |name|
--------------
| 3 | xyz |
--------------
How to avoid it ?
Code is sumthing like this
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
Java code and results sets in a JSP?
Bad bad practice. The database code should be in the model and you should be using the JSTL and EL in the JSP. See this JspFaq entry for more information.
That said, the table element is inside the loop, so of course it's going to be repeated.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Poonam Dhatavkar
Greenhorn
Joined: Jan 11, 2013
Posts: 19
|
|
ohh..Thank you.
I will surely try improving. Any more suggestions ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
Once you have switched to using JSTL, it's easier to see the loops using the <c:forEach> tags and less likely to have these kinds of problems.
If you need some background on how to structure modern web apps, please read this article.
|
 |
Poonam Dhatavkar
Greenhorn
Joined: Jan 11, 2013
Posts: 19
|
|
|
Thank you very much Bear Bibeault :)
|
 |
 |
|
|
subject: table element repeats for multiple rows in JSP
|
|
|