wood burning stoves 2.0*
The moose likes Servlets and the fly likes Tree view in a servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tree view in a servlet?" Watch "Tree view in a servlet?" New topic
Author

Tree view in a servlet?

Ann Toh
Ranch Hand

Joined: Jul 18, 2003
Posts: 45
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

Joined: Jan 10, 2002
Posts: 61106
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
The following might help, even if not all of it is applicable to JavaRanch: http://www.catb.org/~esr/faqs/smart-questions.html


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20545
    ∞

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?


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Ann Toh
Ranch Hand

Joined: Jul 18, 2003
Posts: 45
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

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Jul 18, 2003
Posts: 45
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

Joined: Feb 27, 2002
Posts: 8919

http://www.treemenu.net/treemenu/3fr_largetree.html


Groovy
Ann Toh
Ranch Hand

Joined: Jul 18, 2003
Posts: 45
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

Joined: Jan 23, 2002
Posts: 11962
    
    5

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.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ann Toh
Ranch Hand

Joined: Jul 18, 2003
Posts: 45
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

Joined: Sep 26, 2000
Posts: 24
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tree view in a servlet?