aspose file tools*
The moose likes JSP and the fly likes can we display files and folders separately Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "can we display files and folders separately" Watch "can we display files and folders separately" New topic
Author

can we display files and folders separately

Ramya reenu
Greenhorn

Joined: Nov 28, 2005
Posts: 13
without using "file" option in html can we browse for folders.

like "Browse for folder" option.Giving Folder as input.

thanks in advance
[ December 15, 2005: Message edited by: Ramya Rajakumari ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No, you have no access to the client's file system.

With the file input field, the browser lets the user choose a file but doen't let the javascript control or see anything except the file picked by the user.

Imagine what kinds of horrible security nightmares we would all have to deal with otherwise.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ramya reenu
Greenhorn

Joined: Nov 28, 2005
Posts: 13
I am pointing a folder in the server and from there I would like to browse files and folders which are present inside that pointed folder.
Now I want to display folders in a list box and files in another list box but i am able to display both files and folders in the same list box.so Is there any other way to do the same.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


I am pointing a folder in the server


You want to expose a filesystem on the server? In which case the request processing (the jsp or better a servlet) should do some file related tasks, assemble a list of directories and files and have this data accessible via javascript.

Then it becomes an issue of javascript coding to show the directories and related files in 2 seperate list boxes - the uer chooses a directory in one list box, the other automatically refreshes to show the list of files in that directory.

ram.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ramya Rajakumari:
I am pointing a folder in the server and from there I would like to browse files and folders which are present inside that pointed folder.
Now I want to display folders in a list box and files in another list box but i am able to display both files and folders in the same list box.so Is there any other way to do the same.


On the server, that's different.
Take a look at the isDirectory method of the java.io.File object.
It should provide what you need.
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#isDirectory()
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by ramprasad madathil:


You want to expose a filesystem on the server? In which case the request processing (the jsp or better a servlet) should do some file related tasks, assemble a list of directories and files and have this data accessible via javascript.

Then it becomes an issue of javascript coding to show the directories and related files in 2 seperate list boxes - the uer chooses a directory in one list box, the other automatically refreshes to show the list of files in that directory.

ram.



I agree that this type of work is better done in a servlet than a JSP.
Why would you recommend using Javascript (a client side technology) to sort and separate server side files?
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


Why would you recommend using Javascript (a client side technology) to sort and separate server side files?


I had that classic case in mind, show a list of directories you want to expose in a list box and when the user makes a selection, the other list box refreshes to show the contents of that directory - all on client side.

Yes, I agree, it may become messy.

It's probably the least costly though - get all data (the directories and their list of files in an object structure) and the jsp exposes this object structure to javascript arrays. and then it comes down to that oft repeated question - how do I populate one list box based on the selection in the other

cheers,
ram.
Ramya reenu
Greenhorn

Joined: Nov 28, 2005
Posts: 13
I am able to get it now.Thank you All.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we display files and folders separately