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