File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Unordered list in java for JSP page from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic

Unordered list in java for JSP page from database

Paddu Hegde

Joined: Aug 31, 2008
Posts: 5
Hello Friends,

I was trying to generate unordered lists from database through java code in JSP. I am facing difficulties to generate subcategories in <UL> list.

I have a table with Menu Items :

I want to list get the out put in the form as below :

What i have written is :

Could you please help me where i am wrong.. how should i join the tables? any idea? Could you please help me how to retrieve sub categories and get the output in :


Please help me if you can.. Thanks a lot!


[ September 14, 2008: Message edited by: Paddu Hegde ]
[ September 14, 2008: Message edited by: Paddu Hegde ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

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 to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .

[Asking smart questions] [About Bear] [Books by Bear]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

First of all, note that it is considered extremely poor practice to put Java code in a JSP - especially JDBC code.

I can think of two possible approaches here.
1) Do the query as you are doing and create a Java data structure to represent what you want to output.
2) Write a query to generate the following and use a new entry in the first column to drive the header.
solutions - web
solutions - development
products - softies

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

A solution was provided in your Sun Forums post on this same subject:
Unordered List <UL> generation in JSP.

It is sorta covered in the JavaRanch Style Guide.
subject: Unordered list in java for JSP page from database
It's not a secret anymore!