• 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
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

displaying multiple columns in html table in jsp from mysql database

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I'm finding trouble on how to display more than one column from mysql database table into an html table in jsp. So far I can display rows of only one column using the code below. Someone help me on how I can display say table rows from more than one column.

This is the JSP:



And the DAO that accesses the database:



And the DTO:

 
Sheriff
Posts: 67561
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
Please post an SSCCE of your issue. You've posted way too much unnecessary code to wade through.
 
Kenneth Owino
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Thank you for the reply. Actually, I have a database table with 2 columns "firstname" and "lastname". All I need is to retrieve all the rows in these columns and display them in an html table in my JSP. I read that using JSTL is a good practice and I tried using forEach. In doing this I created 2 DTOs 1 that gets firstname and 1 that gets lastname and two respective DAOs to access the database and returns arrayLists for each of the columns. Now the problem is I'm only able to use one DAO and one DTO that displays the firstname column from the table. How can I make all the columns be displayed? This part of the JSP only displays a table with one column:


How do I add the column under header
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two DTOs? One for firstname, one for lastname?

That doesn't make sense to me. If you're going to get one, you're probably going to want the other.
Why make two trips?

What I would expect is that your DAO layer would return a list of Beans, with all the attributes that you need on them.
So rather than a firstnameDTO, and lastnameDTO, I would expect a StudentDTO which has firstname and lastname attributes (and email, and student id etc etc)

Suggestions on coding style/convention
- Classes should start with a capital letter. fnmDto should be FnmDto.
- fnmDto is a horrible name anyway. I presume it is "first name data transfer object"? Just for readability use "firstName" rather than "fnm"


You then iterate over that list of StudentDTOs, and display the attributes as you wish.

reply
    Bookmark Topic Watch Topic
  • New Topic