File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Help me in tree structure ??????????????????????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Help me in tree structure ???????????????????????" Watch "Help me in tree structure ???????????????????????" New topic
Author

Help me in tree structure ???????????????????????

Ra Sh
Greenhorn

Joined: Jun 17, 2003
Posts: 10
///////////////////////
This is my code ...

<%@ page import="java.util.*,java.io.*" contentType="text/html;charset=x-sjis" %>
<%!
Vector file_list = new Vector();
Vector dir_list = new Vector();
%>
<%!public Vector doMap(File f)
{
File[] allFiles = f.listFiles();
System.out.println("AllallFiles.length"+allFiles.length);
for (int i = 0; i < allFiles.length; i++)
{
if (allFiles[i].isDirectory())
{
doMap(allFiles[i]);
dir_list.add(allFiles[i]);
System.out.println("Directory: " + allFiles[i].toString());
}
else if (allFiles[i].isFile())
// Filter for .jsp files
{
file_list.add(allFiles[i]);
System.out.println("File: " + allFiles[i].toString());
}
}
System.out.println("Vector size"+file_list.size());
return file_list;

}
%>
<%! Vector vc = new Vector();%>
<%
String RequestURI= request.getRequestURI();
String ContextPath= request.getContextPath();
String ServletPath= request.getServletPath();
out.println("RequestURL : "+request.getRequestURL()+"<br>");
out.println("RequestURI : "+RequestURI+"<br>");
out.println("ContextPath : "+ContextPath+"<br>");
out.println("ServletPath or file name : "+ServletPath+"<br>");
String new_st = ContextPath.replaceAll("/","\\\\\\\\");
out.println("ServletPath or file name : "+new_st+"<br>");
out.println("ServletPath or file name : "+request.getRealPath("/")+"<br><br>");
String st = request.getRealPath("/");
File f = new File(st);
vc = doMap(f);
for(int j = 0 ; j<=vc.size()-1 ; j++)
{
out.println(vc.elementAt(j)+"<br>");
}
%>
/////////////////////
//////////////////////
This is o/p I am getting on browser
C:\Tomcat 5.0\webapps\employee\answer.jsp
C:\Tomcat 5.0\webapps\employee\answer1.jsp
C:\Tomcat 5.0\webapps\employee\answer3.jsp
C:\Tomcat 5.0\webapps\employee\ch.jsp
C:\Tomcat 5.0\webapps\employee\checktree.jsp
C:\Tomcat 5.0\webapps\employee\cookie.jsp
C:\Tomcat 5.0\webapps\employee\CustomIcons.java
C:\Tomcat 5.0\webapps\employee\Data\employee.mdb
C:\Tomcat 5.0\webapps\employee\Data\image\236.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\46.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\47.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\48.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\49.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\50.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\51.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\53.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\55.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\56.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\57.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\59.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\60.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\61.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl1.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl10.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl11.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl12.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl13.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl14.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl15.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl16.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl17.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl2.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl5.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl6.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl7.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\girl9.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\leftT.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose1.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose10.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose2.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose3.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose4.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose5.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose6.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose7.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose8.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\rose9.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\Thumbs.db
C:\Tomcat 5.0\webapps\employee\Data\image\titleback.jpg
C:\Tomcat 5.0\webapps\employee\Data\image\Untitled-1.jpg
C:\Tomcat 5.0\webapps\employee\delete.jsp
C:\Tomcat 5.0\webapps\employee\Document2.txt
C:\Tomcat 5.0\webapps\employee\Document3.txt
C:\Tomcat 5.0\webapps\employee\empadd.jsp
C:\Tomcat 5.0\webapps\employee\empaddconfirm.jsp
C:\Tomcat 5.0\webapps\employee\empedit.jsp
C:\Tomcat 5.0\webapps\employee\empinsert.jsp
C:\Tomcat 5.0\webapps\employee\empupdate.jsp
C:\Tomcat 5.0\webapps\employee\exception.jsp
C:\Tomcat 5.0\webapps\employee\Fix\100.jpg
C:\Tomcat 5.0\webapps\employee\Fix\104.jpg
C:\Tomcat 5.0\webapps\employee\Fix\46.jpg
C:\Tomcat 5.0\webapps\employee\Fix\47.jpg
C:\Tomcat 5.0\webapps\employee\Fix\53.jpg
C:\Tomcat 5.0\webapps\employee\Fix\55.jpg
C:\Tomcat 5.0\webapps\employee\Fix\56.jpg
C:\Tomcat 5.0\webapps\employee\Fix\57.jpg
C:\Tomcat 5.0\webapps\employee\Fix\59.jpg
C:\Tomcat 5.0\webapps\employee\Fix\63.jpg
C:\Tomcat 5.0\webapps\employee\Fix\64.jpg
C:\Tomcat 5.0\webapps\employee\Fix\65.jpg
C:\Tomcat 5.0\webapps\employee\Fix\79.jpg
C:\Tomcat 5.0\webapps\employee\Fix\81.jpg
C:\Tomcat 5.0\webapps\employee\Fix\86.jpg
C:\Tomcat 5.0\webapps\employee\Fix\96.jpg
C:\Tomcat 5.0\webapps\employee\Fix\99.jpg
C:\Tomcat 5.0\webapps\employee\include.jsp
C:\Tomcat 5.0\webapps\employee\index.jsp
C:\Tomcat 5.0\webapps\employee\index.jsp1
C:\Tomcat 5.0\webapps\employee\index.jsp2
C:\Tomcat 5.0\webapps\employee\index1.jsp
C:\Tomcat 5.0\webapps\employee\must.txt
C:\Tomcat 5.0\webapps\employee\path.jsp
C:\Tomcat 5.0\webapps\employee\path_26.jsp
C:\Tomcat 5.0\webapps\employee\queries.txt
C:\Tomcat 5.0\webapps\employee\search.jsp
C:\Tomcat 5.0\webapps\employee\security.js
C:\Tomcat 5.0\webapps\employee\tmp0000.jsp
C:\Tomcat 5.0\webapps\employee\tree.jsp
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\File.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\File.jad
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\Files.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\Request.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\SmartUpload.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\SmartUpload.jad
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\com\jspsmart\upload\SmartUploadException.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\EmpAdd.java
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\file\FileUploadBean.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\xutil\XDate.class
C:\Tomcat 5.0\webapps\employee\WEB-INF\classes\xutil\XDate.jad
C:\Tomcat 5.0\webapps\employee\WEB-INF\lib\pager-taglib.jar
C:\Tomcat 5.0\webapps\employee\WEB-INF\pager-taglib.tld
C:\Tomcat 5.0\webapps\employee\WEB-INF\src\XDate.java
C:\Tomcat 5.0\webapps\employee\WEB-INF\web.xml
/////////////////////
/////////////////////
This is I want
data
----image
---------imagefile.jpg
fix
temp
web-inf
------classes
-------------com
----------------jspsmart
------lib
///////////////////////
please help me out
If you send code that will be appreciated
Tx in advance
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

public Set getResourcePaths(String path)Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. Paths indicating subdirectory paths end with a '/'. The returned paths are all relative to the root of the web application and have a leading '/'. For example, for a web application containing
/welcome.html
/catalog/index.html
/catalog/products.html
/catalog/offers/books.html
/catalog/offers/music.html
/customer/login.jsp
/WEB-INF/web.xml
/WEB-INF/classes/com.acme.OrderServlet.class,
</font>
[ September 27, 2003: Message edited by: Pradeep Bhat ]

Groovy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help me in tree structure ???????????????????????