Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am assuming it's a small scale project.<br> First maintain a database for your books.. give each of 'em an unique id. If you are display all the common details like... published on, price, book name, author, reviews, rating.... Then you don't need to worry.. Create a common JSP Page to display the indo based on an uniqueId...</p> <p><strong>jsp say: books.jsp</strong></p> <pre><code>&lt;form name="books" action="getInfo.jsp"&gt; &lt;a href="YourJSP/?bookid=pass_an_id_for_your_bookX"&gt;Book X(Image)&lt;/a&gt; //Book X &lt;a href="YourJSP/?bookid=pass_an_id_for_your_bookY"&gt;Book Y(Image)&lt;/a&gt; //Book Y &lt;a href="YourJSP/?bookid=pass_an_id_for_your_bookZ"&gt;Book Z(Image)&lt;/a&gt; //Book Z .... .... an on.. &lt;/form&gt; </code></pre> <p>?bookid will be your paramid.<br> pass_an_id_for_your_bookX will be your unique id of your bookX stored in database.</p> <p><strong>inside your 2nd JSP say: getInfo.jsp</strong></p> <p>Design your JSP for presentation, to diplay info about your BookX / BookY w.r.t to bookId In your JSP get the value of bookId and query the DB... </p> <pre><code> String bookId = request.getParameter("bookid"): //This will get the value of your bookId for BookX //Connect to your DB //Use PreparedStatement or StoredProcedure to make a query pass your bookId in where condition. </code></pre> <p>Rest is simple, By Querying the database you will all the usual values ie. published on, price, book name, author, reviews, rating... and display them accordingly in your JSP page.. </p> <pre><code> &lt;% Connection con = null; PreparedStatement pst = null; ResultSet rs = null; String BookName=null; String AuthorName=null; String Price=null; String Rating=null; try { Class.forName(driver); con = DriverManager.getConnection(connection); String sql = "select * from BOOKS_TABLE where bookId =?"; pst = con.prepareStatement(sql); pst.setString(1, bookId); rs = pst.executeQuery(); while (rs.next()) { BookName = rs.getString(1); AuthorName = rs.getString(2); Price = rs.getString(3); Rating = rs.getString(4); } // 1 , 2, 3... denotes column numbers } catch (SQLException e) { System.out.println(e.getMessage()); } } } %&gt; </code></pre> <p>Now you got all your values.. Well, display them accordingly.. </p> <pre><code> &lt;%=BookName%&gt; &lt;%=AuthorName%&gt; &lt;%=Price%&gt; &lt;%=Rating%&gt; </code></pre> <p><strong>A Note:</strong> Scriplets(Java Code) are not encouraged in JSP page.. You may want to check into Beans or JSTL. I'm just giving you an IDEA!</p> <p>ALL THE BEST</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload