• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating a tree in JSP

 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am a newbie in JSPs and would like to have some help with the following problem, I would like to create a tree structure in JSP, say for example depicting the directory structure in windows. The directory structure looks like this

Root
My Computer
C:
test.txt
data.dat
D:
test1.txt
faq.txt
ANOTHER_DIR
xxx1.text
YYY1.dat
My Documents
My Pictures

Under this structure each file if it is a directory,has more files. What would be the best manner in which to achieve this. Would it be to parse the directory structure using J2SE, write it to a XML document and to process this document using JSP or is there any other easier way.

Thanks

Vijai
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check Jenkov JSP Tree Tag and JSP Tree Tag.
 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, but I would also like to know how to get the whole directory hierarchy across to the JSP, for example,

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They must be having provision for it. Just check the documentation.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of years ago I wrote a bean to facilitate presenting a file system tree in JSP and allowing the user to browse it and forward a selected directory/file to a servlet. Here is the bean code:

In the JSP you have to provide for setting the parameters that control which roots of the file system are browsable - the JSP I used looks like:


Note that the bean does all the HTML formatting and that CSS controls the appearance of directories and files.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic