Results 1 to 8 of 8
  1. #1
    IDForums is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default Resultset to HTML Table

    I have a resultset like this:

    year type total
    2009 A 123
    2009 B 223
    2010 A 123

    How should I display above resultset in the form of a HTML table attached.

    Thanks.
    Attached Thumbnails Attached Thumbnails Resultset to HTML Table-html.jpg  

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    IDForums is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default

    Yes Eranga

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Could be done in many ways. But you should explain what you exactly want to do this, how, where you going to display it and so on...

    You can create a string with concatenating all the required html tags to in to string. But you have to display the text in HTML support control, like a label and so on.

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by IDForums View Post
    I have a resultset like this:

    year type total
    2009 A 123
    2009 B 223
    2010 A 123

    How should I display above resultset in the form of a HTML table attached.

    Thanks.
    Where do you have that resultset?
    What format is it in?

    The normal way of creating tables is to create the header first (c:foreach creating <th> tags) then creating the rows in the table body (c:foreach creating <tr> tags).

  6. #6
    Gunas is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    It needs some processing on the result set data before it get displayed.
    Please make it clear, from where you are trying to generate it, like
    1. As a servlet outptut
    2. In a JSP page
    Then it will easy for us to give solution.
    Note: If you found the soulution,please share here for others.

  7. #7
    IDForums is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default

    I am generating it on a JSP page. As I loop though the arraylist that I build from DB Resultset, the problem is HTML table has to be constructed row by row. In the sense, each block below needs to be filled before I jump to the next col.
    < tr>
    < td>
    2009
    </td>
    2010
    < td>
    </td>
    </tr>

    But my ArrayList is a list of Objects containing member variables as Year, Type, Total. When I loop though this list, I get all data pertaining to 2009 first and then only 2010.

    Let me know if this post needs to be detailed more. Looking for some help

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Did you read the post which had

    "The normal way of creating tables is to create the header first (c:foreach creating <th> tags) then creating the rows in the table body (c:foreach creating <tr> tags)."
    ?
    If you did, what did you do about it?

Similar Threads

  1. Formatting resultset for html
    By davwhite in forum New To Java
    Replies: 0
    Last Post: 05-26-2008, 08:07 PM
  2. Generate Excel Report from a HTML table
    By Sudha in forum New To Java
    Replies: 0
    Last Post: 02-13-2008, 08:24 PM
  3. ResultSet to HTML
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-12-2008, 09:32 AM
  4. Problem with applying Sql order by to html table
    By sireesha264 in forum Advanced Java
    Replies: 2
    Last Post: 02-04-2008, 10:20 AM
  5. Showing ResultSet in HTML table
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-27-2008, 08:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •