• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • 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: 67645
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: 67645
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 :)
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic