Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we display files and folders separately

 
Ramya reenu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ramya reenu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to get it now.Thank you All.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic