#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    19
    Rep Power
    0

    display data in certain number of rows


    after i retrieve the data from the database, there is a very long list of data. is there a way to display them in rows of ten or twenty?

    What i have now is:

    <%
    while (rs.next())
    {
    <% out.println(rs.getString(1));
    %>

    <%}
    rs.close();
    statement.close();
    %>

    Pls help....
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Do you mean display the first 10, or display 10 per page with multiple pages?
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    19
    Rep Power
    0
    display 10 per page with multiple pages
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    16
    Rep Power
    0
    There are taglibs that will let you do what you want, or you can write your own classes that let you do what you want.

    I did the latter. A summary:

    A DataGrid class holds the data. Keeping a ResultSet object open ties up db resources, so the data is transferred to a List of Lists inside the DataGrid object. DataGrid has a constructor that takes a ResultSet as an argument.

    A PaginatedReport object displays the data. It has a DataGrid as a field as well as pageSize and currentPage ints. It has previous(), next() setPage() methods that navigate thru pages, and a toHTMLTable method that spits out the data in a single String in HTML format.

    So the steps are:

    1. get the ResultSet from your db.
    2. create a DataGrid from the ResultSet
    3. create a PaginatedReport from the DataGrid
    4.put the PaginatedReport in the session
    5. call toHTMLTable on the PaginatedReport object.
    6. put "next" and "previous" links on your page, and add logic to the jsp to call the next() or previous() methods of the PaginatedReport.
  8. #5
  9. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    19
    Rep Power
    0
    wat are the taglibs???

    i dunno how to write the class..
  10. #6
  11. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
  12. #7
  13. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    19
    Rep Power
    0
    i don't understand what the storing of data in a java bean mean...
    is it possible to show me the codes???

    currently, i have:

    <%

    while(rs.next()){
    String srno = rs.getString(1);
    %>
    <tr>
    <td width="10%"><font size=2>
    <a href="checkboxselect.jsp?srno=<%= srno%>"> <%= srno%>
    <!-- <% out.println(rs.getString(1));%> -->
    </a> </font></td>
    <td width="11%"><font size=2>
    <% out.println(rs.getString(2));%>
    </font></td>
    <td width="11%"><font size=2>
    <% out.println(rs.getString(3));%>
  14. #8
  15. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Here's a link off that page. A taglib to do it all for you Read the docs. http://jsptags.com/tags/navigation/pager/
  16. #9
  17. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    19
    Rep Power
    0
    after i download the executable jar, what do i do???
  18. #10
  19. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Read the documentation under "installation".
  20. #11
  21. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    19
    Rep Power
    0
    my tomcat server is an integrated version therefore it does not have the folder that it mention.

    is there another way like using short jsp codes instead???
  22. #12
  23. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Well, the source for the taglib is included in a jar file in the download, so you could reimplement the classes that do the work and use them stand-alone.
    However, I'm willing to bet your IDE comes with documentation on how to enable a custom taglib. Check it's help page.

IMN logo majestic logo threadwatch logo seochat tools logo