By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,032 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,032 IT Pros & Developers. It's quick & easy.

generating menu from DB in jsp

P: n/a
waa
Hi,
I want to generate a side menu from a database list and sort it
alphabetically.
I am not please with what i get which is NOT alphabetical.
Below are my codes:
--------BEAN-------------------------------------
public static void loadAllCategories() throws ProductActivityException
{
if (allLoaded) return;
Category cat = null;
try
{
dbConn = ConnectionFactory.getConnection();
if(dbConn == null)
{
System.out.println("Couldnt get DB Connection");
throw new CustomerActivityException();
}
PreparedStatement pstmt
=dbConn.prepareStatement(sql_bundle.getString("fin dAllCats"));
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{findCategory(rs.getString("CATEGORY_NAME")); }
rs.close();
pstmt.close();
}
catch (Exception e)
{
System.out.println("Error during loadAllCategories");
e.printStackTrace();
throw new ProductActivityException();
}
finally
{
try { dbConn.close(); }
catch (Exception e) { System.out.println("Error during
releaseConnection");}
}
allLoaded = true;
}
-------------------------JSP------------------------------------------------
<%
Category.loadAllCategories();
Iterator it = Category.getCategories().iterator();
while (it.hasNext())
{
String catName = (String) it.next();
%>
<a class="menuleft" href="Category.jsp?category=<%= catName %>">
<%= catName %>
</a>
<br>
<%
}
%>
------------------DB------------------------------------
SELECT CATEGORY_NAME FROM CATEGORY ORDER BY CATEGORY_NAME ASC;
The reult I get from this in MySQL is satisfactory. But JSP displays
it differently.

Anyone there with an idea.Thanks.
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.