• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tree view in a servlet?

 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
can anyone tell me how to write a tree view in a servlet??
i hav gone to this website http://www.servletsuite.com/servlets/treetag.htm and i hav download its jar file but i do not know how to write it into a servlet. so can anybody tell me how??
Thanx in advance...

[ October 08, 2003: Message edited by: Michael Ernest ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ann,
This is the fifth time in the past week that you have posted this exact same question. If you are not getting answers to your question, it may be because: no one knows the answer, it cannot be done, or you are not framing the question with enough information for anyone to try and help you.
Repeated postings will not get you any better or faster answers. If you are not getting answers to your question, you should elaborate on what you are trying to do in the topic that you have already started.
And, using 'urgent' in your subject rather than a meaningful phrase will usually get your topic ignored by some of the best answerers in these forums. It's seen as rude -- sort of like trying to push ahead in line at the grocery store.
I'm not trying to be mean or anything, but you are not making effective use of these forums as a resource.
hth,
bear
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following might help, even if not all of it is applicable to JavaRanch: http://www.catb.org/~esr/faqs/smart-questions.html
 
paul wheaton
Trailboss
Pie
Posts: 21385
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your servlet going to be stateless?
Are you wanting one of those trees that's using the "+" and "-" stuff? Or, do you just want to show the whole tree?
It would seem that if you want to use a specific product, you would want the assistance of those folks, unless it is such a popular product that lots of other people use it (like tomcat or jboss).
Are you for sure using that product, or are you willing to try doing it from scratch?
Are you familiar with servlets and html in general?
 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul Wheaton,
thanx for ur help...i want those trees to have "+" and "-". Actually, i want the tree to show a directory structure juz like the window explorer.
i would like to use the product to do my program, but if there is other better product, i would use that.
im quite new in servlets, im not so familiar with servlets yet..
Do u hav any idea on how to write trees in servlet??
thanx...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me what you want is better created using JavaScript - JavaScript can dynamically change the display on the user's browser WITHOUT going back to the server. There are tons of JavaScript resources on the net.
Once you have created a prototype page that does the display you want, then you can work on creating a page dynamically from a servlet or JSP.
Bill
 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
can anybody tell me how to know whether the user has click one of the nodes in the tree?? i'm writing in a servlet prog to write into a jsp file.
thanx in advance...

[ October 10, 2003: Message edited by: Ann Toh ]
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The program is what im currently doing. I write the program into a jsp file then i redirect it to the jsp file to display. Can anybody tell me how do i noe whether the user has click which node, and i need to display things that are related to the nodes that the user has juz click??
fos = new FileOutputStream("C:\\Tomcat 4.1\\webapps\\SDC1\\myfile.jsp");
// Connect print stream to the output stream
p = new PrintStream(fos);

p.println("<html>");
p.println("<head>");
p.println("<title>Files</title>");
p.println("</head>");

p.println("<body bgcolor=\"#ECDFCE\" link=\"blue\" vlink=\"purple\" alink=\"red\" style=\"scrollbar-face-color:#F5DEB3; scrollbar-arrow-color:indianred; scrollbar-track-color : papayawhip; scrollbar-shadow-color:black; scrollbar-highlight-color:''; scrollbar-3dlight-color:#BC7E41; scrollbar-darkshadow-Color:maroon;\" >");
p.println("<table width=\"100%\">");
p.println("<tr>");
p.println("<td width=\"50%\">");

File parentNode = new File(dirName + "\\" + user);

if (parentNode.isDirectory())
{
File[] childNode = parentNode.listFiles();

String parentName = parentNode.getName();

p.println("<%@ taglib uri=\"taglib.tld\" prefix=\"tree\" %>");

p.println("<tree:createTree treePicture=\"images/folder_idle.gif\" nodePicture=\"images/item_doc.gif\" openPicture=\"images/folder_open.gif\" dhtml=\"true\">");
p.println("<tree:addNode code=\"<b>" + parentName + "</b>\">");

for (int i = 0; i < childNode.length; i++)
{
String fileInDir = childNode[i].getName();
addnode.setCode(fileInDir);
String node = addnode.getCode();

if (childNode[i].isDirectory())
{
expandFiles(childNode[i].getAbsoluteFile());
}
}

p.println("</tree:addNode>");
p.println("</tree:createTree>");
}

thanx in advance...

[ October 15, 2003: Message edited by: Ann Toh ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ann, the taglibs can only be used in a JSP. If you write the taglib tags into the HTML document being sent to the browser, the browser will think "what the heck is this" and either display an error or simply ignore the unrecognized elements.
 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lasse Koskela,
i know that the taglib can only be in jsp file. In this program, i write the tree structure into a jsp file called myfile.jsp. The servlet will run the program and write it into myfile.jsp, after writing it to the myfile.jsp, the servlet will call myfile.jsp to display the tree. the program does work but there is one problem, that is how do i noe whether the user has click which nodes??
 
san jan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One simple thing is make that '+' a html link or any other html element that has onclick functionality in javascript (if u can also use javascript).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic