• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

table element repeats for multiple rows in JSP

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Poonam Dhatavkar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohh..Thank you.
I will surely try improving. Any more suggestions ?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Bear Bibeault :)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic