| Author |
Part of the code is not working in jsp
|
Rashmi Dupati
Greenhorn
Joined: Mar 05, 2007
Posts: 22
|
|
Hello please check the code and give the solution to my problem. <%@ page import="java.util.*" %> <jsp:useBean id="dbBean" scope="application" class="burnaby.DbBean"/> <% String base = (String) application.getAttribute("base"); %> <TABLE CELLSPACING="0" CELLPADDING="5" WIDTH="150" BORDER="0"> <TR> <TD BGCOLOR="F6F6F6"> <FONT FACE="Verdana">Search</FONT> <FORM> <INPUT TYPE="HIDDEN" NAME="action" VALUE="search"> <INPUT TYPE="TEXT" NAME="keyword" SIZE="10"> <INPUT type="SUBMIT" VALUE="Go"> </FORM> </TD> </TR> <TR> <TD BGCOLOR="F6F6F6"><FONT FACE="Verdana">Categories:</FONT></TD> </TR> <TR VALIGN="TOP"> <TD BGCOLOR="F6F6F6"> (up to this working fine the below scriplet is not working.it's not displaying categories accessing from database) <% Hashtable categories = dbBean.getCategories(); Enumeration categoryIds = categories.keys(); while (categoryIds.hasMoreElements()) { Object categoryId = categoryIds.nextElement(); out.println("<A HREF=" + base + "?action=browseCatalog&categoryId=" + categoryId.toString() + ">" + categories.get(categoryId) + "</A><BR>"); } %> </TD> </TR> </TABLE> and see the DbBean code also public Hashtable getCategories() { Hashtable categories = new Hashtable(); try { Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword); System.out.println("got connection"+dbUrl); Statement s = connection.createStatement(); String sql = "SELECT categoryId, category FROM Categories" + " "; System.out.println("executing"); ResultSet rs = s.executeQuery(sql); while (rs.next()) { categories.put(rs.getString(1), rs.getString(2) ); } rs.close(); s.close(); connection.close(); } catch (SQLException e) {} return categories; } thanks in advance
|
 |
Rodrigo Tomita
Ranch Hand
Joined: Apr 28, 2008
Posts: 70
|
|
Rashmi, Well, if nothing is printed out in your HTML, probably your ResultSet has no rows. I believe you could try to add a print statement to check that.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56230
|
|
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information. You can go back and change your post to add code tags by clicking the .
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Santosh Kolekar
Greenhorn
Joined: Jul 10, 2008
Posts: 6
|
|
Hi Rashmi, you have not post what err you getting. plese post err msg. Also check whether it works by following change. Enumeration categoryIds = categories.iterator(); ALL THE BEST
|
Santosh Kolekar<br />SCJP,SCWCD,Preparing..SCBCD
|
 |
Santosh Kolekar
Greenhorn
Joined: Jul 10, 2008
Posts: 6
|
|
Hi Rashmi, Try it by iterator. in my previous post i mentioned Enumeration categoryIds = categories.iterator(); plese replace it as Iterator categoryIds = categories.iterator(); All The Best
|
 |
 |
|
|
subject: Part of the code is not working in jsp
|
|
|