User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 426,423 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,365 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 536 | Replies: 1
Join Date: Apr 2008
Posts: 1
Reputation: koushika is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
koushika koushika is offline Offline
Newbie Poster

how to select the isbn number in table and get all books of isbn selected

  #1  
Apr 1st, 2008
i have a table displayed with bookisbn , booktitle and bookauthor etc..in which i have to make the bookisbn column values as hyperlink to a page name bookinfo.jsp which will diplay all copies of the book under the clicked isbn number .
i am attaching the code below:

{code viewbooksforsale.info which displays all books in database and has values of isbn column as hyperlinks}
  1. <?xml version="1.0" encoding ="UTF-8"?>
  2. <%-- file location of the jsp --%>
  3. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  4. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
  5. <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
  6. <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
  7. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
  8.  
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  10. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html>
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  14. <title>Books For Sale</title>
  15. </head>
  16. <body>
  17. <%--debugging code--%>
  18. <%@ include file="debug.jsp" %>
  19.  
  20. ONLINE BOOK TRADING SYSTEM
  21.  
  22. <c:url var="HmePgeURL" value="/cw/router/home" scope="page"/>
  23. <a href="${HmePgeURL}">Home</a> <c:url var="BSPgeURL" value="/cw/router/login" scope="page"/>
  24. <a href="${BSPgeURL}">Buy or Sell</a> <c:url var="UregPgeURL" value="/cw/router/userregistration" scope="page"/>
  25. <a href="${UregPgeURL}">User Registration</a>
  26.  
  27. <%-- check for database Error --%>
  28. <c:if test="${!empty requestScope.reqQueryErrorMessage}" var="pgeDatabaseError" scope="page"> Database Error </c:if>
  29. <%-- check for empty item table --%>
  30. <c:if test="${not pgeDatabaseError}">
  31. <c:if test="${booksFromQuery.rowCount == 0}" var= "pgeEmptyTable" scope="page" >
  32. There Are No Items In The Table
  33. </c:if>
  34. </c:if>
  35.  
  36. Books For Sale !
  37. <%-- Display Books --%>
  38. <c:if test="${not pgeDatabaseError and not pgeEmptyTable}">
  39. <table border="1" align="center" cellpadding="2" cellspacing="0" width ="984">
  40. <tr bgcolor="#66CCFF">
  41. <td width="15">
  42. ISBN
  43. </td>
  44. <td width="268">
  45. Title
  46. </td>
  47. <td width="198">
  48. Author
  49. </td>
  50. <td width="10">
  51. Price
  52. </td>
  53. <td width="15">
  54. Condition
  55. </td>
  56. <td width="15">
  57. Status
  58. </td>
  59. </tr>
  60. <c:forEach items="${booksFromQuery.rows}" var="myRow">
  61. <tr><c:url var="BookInfoPgeURL" value="/cw/router/viewbookinfo" scope="page"/>
  62. <td width="15">
  63. <a href= "$BookInfoPgeURL" onclick="afadf">${myRow.dbItemISBN}</a>
  64. </td>
  65. <c:set var="ISBNselected" value="${myRow.dbItemISBN}" scope="request" />
  66. <td width="268">
  67. ${myRow.dbItemTitle}
  68. </td>
  69. <td width="198">
  70. ${myRow.dbItemAuthor}
  71. </td>
  72. <td width="10">
  73. ${myRow.dbItemPrice}
  74. </td>
  75. <td width="15">
  76. ${myRow.dbItemCondition}
  77. </td>
  78. <td width="15">
  79. ${myRow.dbItemStatus}
  80. </td>
  81. </tr>
  82. </c:forEach>
  83. </table>
  84. </c:if>
  85. <%-- debugging code --%>
  86. <%-- for local page-scoped objects --%>
  87. <c:if test="${sessDebug == 'true'}">
  88. <table border="1">
  89. <c:forEach var="item" items="${pageScope}">
  90. <tr>
  91. <td>pageScope object</td>
  92. <td>${item.key}</td>
  93. <td>${item.value}</td>
  94. </tr>
  95. </c:forEach>
  96. </table>
  97. </c:if>
  98. </body>
  99. </html>

*


*{code viewbookinfo.jsp generated view once a user selects an isbn number in viewbookforsales.jsp } *
  1. <?xml version="1.0" encoding ="UTF-8"?>
  2. <%-- file location of the jsp --%>
  3. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  4. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
  5. <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
  6. <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
  7. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  12. <title>BOOK INFO</title>
  13. </head>
  14.  
  15. <body>
  16. <div align="center"><c:url var="HmePgeURL" value="/cw/router/home" scope="page"/><a href="${HmePgeURL}">Home</a> <c:url var="BSPgeURL" value="/cw/router/login" scope="page"/>
  17. <a href="${BSPgeURL}">Buy or Sell</a> <c:url var="UregPgeURL" value="/cw/router/userregistration" scope="page"/>
  18. <c:url var='pgeviewbooksURL' value='/cw/router/viewbooksforsale' scope='page'/><a href="${pgeviewbooksURL}">Online Book Sale</a>
  19. </div>
  20. <%-- check for database Error --%>
  21. <c:if test="${!empty requestScope.reqQueryErrorMessage}" var="pgeDatabaseError" scope="page"> Database Error </c:if>
  22. <%-- check for empty item table --%>
  23. <c:if test="${not pgeDatabaseError}">
  24. <c:if test="${booksinfoFromQuery.rowCount == 0}" var= "pgeEmptyTable" scope="page" >
  25. There Are No Items In The Table
  26. </c:if>
  27. </c:if>
  28. <%-- display book info --%>
  29. <c:if test= "${not pgeDatabaseError and not pgeEmptyTable}">
  30. <p align="center"> </p>
  31. <div align="center">
  32. <table width="359" cellpadding="5">
  33. <tr>
  34. <td width="187"><label>COPIES AVAILABLE</label> </td>
  35. <td width="144"><input name="textfield" type="text" value="${fn:length(items}" /></td>
  36. </tr>
  37. </table>
  38. </div>
  39. <c:forEach items="${booksinfoFromQuery.rows}" var="myRow">
  40. <p align="center"> </p>
  41. <div align="center">
  42. <table width="671" cellpadding="5">
  43. <tr>
  44. <td>ITEM ID </td>
  45. <td><input type="text" name="textfield" value="${myRow.dbItemId}"/></td>
  46. </tr>
  47. <tr>
  48. <td width="209"><label>ISBN</label> </td>
  49. <td width="434"><input type="text" name="textfield" value="${myRow.dbItemISBN} "/></td>
  50. </tr>
  51. <tr>
  52. <td><label>TITLE</label> </td>
  53. <td><input name="text" type="text" value="${myRow.dbItemTitle}" /></td>
  54. </tr>
  55. <tr>
  56. <td><label>AUTHOR</label> </td>
  57. <td><input name="textarea" type="text" value="${myRow.dbItemAuthor}" /></td>
  58. </tr>
  59. <tr>
  60. <td><label>BOOK INFO </label> </td>
  61. <td><input name="textarea" type="text" value="${myRow.dbItemInfo}" /></td>
  62. </tr>
  63. <tr>
  64. <td><label>CONDITION</label> </td>
  65. <td><input type="text" name="textfield" value="${myRow.dbItemCondition} " /></td>
  66. </tr>
  67. <tr>
  68. <td><label>STATUS</label> </td>
  69. <td><input type="text" name="textfield" value="${myRow.dbItemStatus}"/></td>
  70. </tr>
  71. <tr>
  72. <td><label>PRICE</label> </td>
  73. <td><input type="text" name="textfield" value="${myRow.dbItemPrice}"/></td>
  74. </tr>
  75. <hr />
  76. </table>
  77. </div>
  78. </c:forEach>
  79. </c:if>
*



{code probookinfo.jsp -- process jsp file for viewbookinfo.jsp}
  1. <?xml version="1.0" encoding ="UTF-8"?>
  2. <%-- \WEB-INF\jsp\cwjsps\probookinfo.jsp --%>
  3. <%-- Probookinfo --%>
  4. <%-- file location of the jsp --%>
  5. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  6. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
  7. <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
  8. <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
  9. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
  10. <%-- execute the query --%>
  11. <c:catch var="pgeQueryError">
  12. <sql:query var="booksinfoFromQuery" scope="request">
  13. SELECT dbItemId,dbItemInfo,dbItemISBN,dbItemTitle,dbItemAuthor,dbItemPrice,dbItemCondition,dbItemStatus FROM item WHERE dbItemISBN ="${ISBNselected}"
  14. </sql:query>
  15. </c:catch>
  16.  
  17. <%-- check query error --%>
  18. <c:choose>
  19. <c:when test="${not empty pgeQueryError}">
  20. <%-- Database Error --%>
  21. <c:set var="reqOutcome" scope="session" value="failure" />
  22. <c:set var="reqQueryErrorMessage" scope="request" value="${pgeQueryError.message}" />
  23. <jsp:forward page="/WEB-INF/jsp/cwjsps/test.jsp"/>
  24. </c:when>
  25. <c:otherwise>
  26. <c:set var="reqOutcome" scope="session" value="success" />
  27. </c:otherwise>
  28. </c:choose>
  29. <jsp:forward page="/WEB-INF/jsp/cwjsps/viewbookinfo.jsp"/> <%-- display book info --%>
  30. <%-- display trader own page after login --%>
Last edited by peter_budo : Apr 3rd, 2008 at 11:19 am. Reason: Changed {code} to [code]
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JSP Forum

All times are GMT -4. The time now is 2:14 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC