File Explorer in Java


I am trying to use file explorer in my java struts app. I am using dynamic tree loading concept.

First of all my tree works in IE but not FF it says " XML or text declaration not start of entity" here is the jsp that I am calling

<%@ page import=“com.beans.CreateFolderTree”%>


out.println(“<?xml version=\"1.0\" encoding=\"UTF-8\"?>”);

CreateFolderTree navFol = null;

navFol = new CreateFolderTree();

System.out.println(“Inside JSP: “);

String strTree2 = navFol.getTree();

System.out.println(“strTree2: “+strTree2);



whats wrong in this?

2. In dynamic tree loading when u click on the node u need to send the ID of node in URL inorder to create XML for the node

how do I get the node ID to send it in the URL for serXMLAutoLoading





        var sID = tree.getSelectedItemId();

        alert("Selected Node: " + sID);

        alert("This node has children: "+tree.hasChildren(sID));


I am new to this trying to redesign outr webpages with file explorer

>> First of all my tree works in IE but not FF it says " XML or text declaration not start of entity" here is the jsp that I am calling

In case of FF the problem may occur because of any whitespace before <?xml declaraton (the declaration must be the first text in the output).

>> how do I get the node ID to send it in the URL for serXMLAutoLoading

You can use onXLE event:



I was able to fix the problem I had with FF.

But the second Issue regarding dynamic loading of tree menu how do I get the ID of the node that is clicked to send it in the URL used for tree.setXMLAutoLoading(url)

Ex: I have to call this URL in which I ahve to send the ID as query Parameter  “/web/”



The id is sent automatically (the parameter name is id).

Please, read the article … ml#dyntree

So Can I just do request.getParameter(“id”) in my server side program?

and set tree.setXMLAutoLoading("/web/")


Yes, you can.

I tried that. I am not getting ID in my server side program  :

ID from Tree: undefined

Here is what I has in my HTML






Here is what I had in my action class


class XMLGrid extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response)

throws Exception {


System.out.println("ID from Tree: ");

String id = request.getParameter(“id”);

System.out.println("ID from Tree: "+ id);

PrintWriter out = response.getWriter();

response.setContentType(“text/xml; charset=iso-8859-1”);

response.setHeader(“Cache-Control”, “no-store, max-age=0, no-cache, must-revalidate”);

response.addHeader(“Cache-Control”, “post-check=0, pre-check=0”);

response.setHeader(“Pragma”, “no-cache”);

out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

CreateFolderTree navFol = null;

navFol = new CreateFolderTree(“netlib”, “dmadmin”,“180washington”, “/” + “NSS”);

System.out.println("Inside JSP: ");

String strTree2 = navFol.getTree();

System.out.println("strTree2: "+strTree2);



return null;

} catch (Exception e){

return null;




This is my Intial XML

<?xml version=\"1.0\" encoding=\"UTF-8\"?>

When I click on one of these Items I need the value spcified in the ID in the above XML in the server side program.

I got it in My XML I had id specified in uppercase ID="" thats y it didn’t get the value.

The correct root xml is:

<?xml version="1.0" encoding="UTF-8"?>

<item text=“DocResources” id="/NSS/DocResources" im0=“folderClosed.gif” child=“1”/>

<item text=“Exec” id="/NSS/Exec" im0=“folderClosed.gif” child=“1”/>

<item text="_ApplicationsOps-Eng" id="/NSS/_ApplicationsOps-Eng" im0=“folderClosed.gif” child=“1”/>

<item text="_ApplicationsRF-Perf" id="/NSS/_ApplicationsRF-Perf" im0=“folderClosed.gif” child=“1”/>

Please, check case of teh id attribute

Thanks for ur help Alex