*
The moose likes Java in General and the fly likes Using JFileChooser in a webapplication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using JFileChooser in a webapplication" Watch "Using JFileChooser in a webapplication" New topic
Author

Using JFileChooser in a webapplication

sadanand munswamy
Ranch Hand

Joined: Apr 10, 2012
Posts: 39
Hi All,
I need to use JFileChooser in my web-application, any help will be deeply
appropriated.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37874
    
  22
You didn’t say what you know about file choosers already, so I shall give you a Java tutorials link.
sadanand munswamy
Ranch Hand

Joined: Apr 10, 2012
Posts: 39
Dear Campbell Ritchie,
I have been doing java for a long time, So i do know it.
Some how i need to invoke a file chooser from my web-application that should allow
the user to choose only directory and no files.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

You can only use a JFileChooser in combination with an applet. Because of the applet's security restrictions, it needs to be signed first.

The important question is, however, why you need to let users select a directory. Using a JFileChooser would let the user choose a local directory where the server has no access to (other than through the applet, but only while the applet is active). Is that what you want? Or do you want the user to select a directory on the server? In that case, perhaps you can build some HTML based file browser yourself (or find some existing code to do that). Make sure that the user cannot select just any directory; keep the selection as limited as possible.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
sadanand munswamy
Ranch Hand

Joined: Apr 10, 2012
Posts: 39
Hey Rob,
Thanks for your valuable insights, And you are absolutely correct, as i need to choose any directory
from the server and not the local. Is there any read to use html file chooser, which can do the trick for me.
Thanks Again.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Check out http://stackoverflow.com/questions/9068156/server-side-file-browsing. You may need to tweak it a bit to get it to show only directories.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using JFileChooser in a webapplication
 
Similar Threads
File browser crash course
Folder Selector
Simple file browser !!!!!!
Is there any Browse button control in Swing ??
how to write coding for browse button in java swing?