Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Unanswered: How to select a range of records using JSP

    I have a list of books

    book 1
    book 2
    book 3
    ...
    ....
    book 10
    ....

    book 20

    Now I want to display book 1 to book 10 on one page and
    book 10 to book 20 on another page

    So I need to select first 10 books using SQL query and then the next 10

    Code:
    <html>
    <body>
    <&#37;@ page import="java.sql.*,java.awt.Image" %>
    <%
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=null;
    conn = DriverManager.getConnection("jdbc:odbc:bookstore", "", "");
    Statement s = conn.createStatement();
    
    
    ResultSet r = s.executeQuery("select * from book where CateID=6");
    while(r.next()) {%>
    <TABLE BORDER=10 bgcolor="white">
    <TR>
    <TD>Title
    <% out.print(r.getString("title"));%></TD>
    <TD>Cost<% out.print(r.getString("price"));%></TD>
    <TD>Image <img src="<%out.print(r.getString("ISBN"));%>.jpg"></TD>
    <TD>ISBN</TD>
    <%
    }

    as you can see (select * from book where CateID=6) will display all books.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so is this a Java question or a Access question or a JET Question?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2009
    Posts
    2

    Got it!

    I solved it using a few if and while statements.

Posting Permissions

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