File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes TreeView in JSP ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "TreeView in JSP ?" Watch "TreeView in JSP ?" New topic

TreeView in JSP ?

vijay mahendra
Ranch Hand

Joined: Jan 01, 2007
Posts: 51

I need to display dynamic data as tree view using JSP page.
Is there any tags in jsp to display treeview or anyother choice.

Data should access from Database dynamically not static data

if any please help me in this.

thank you all.
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
If you are familiar with javascript objects, you can create a tree kind structure using javascripts and you can display on the screen, this is advance option if you want the tree leaves to be expanded and some action needs to happen.check this URL( )

Else If you just want to display the tree without providing and action to the tree you can use something like this.

The table would have a structure similar to the following:

col 1col 2col 3col 4
col 1.0   
 buttoncol 2.0  
  buttoncol 3.0 
   buttoncol 4.0
col 1.1   
 buttoncol 2.1  
col 1.2   
 buttoncol 2.2  
 button col 3.2 

A reasonably simple Map based data structute should be sufficient to help stored the data model while the table is generated. When generating the HTML, if you turn off all the cell borders then you'll have something that looks much like a tree. If you add little buttons to the cells as indicated by 'button' and write some code behind them then you can use them to collapse/expand individual nodes in the tree. This collapsing/expanding could be done client side (using JavaScritpt and DIV elements wrapping the cells to hide/display) or server side (re-generate the table for that request with certain rows included/excluded).

SCJP 1.2
I agree. Here's the link:
subject: TreeView in JSP ?
It's not a secret anymore!