Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / May 2005

Tip: Looking for answers? Try searching our database.

applet read file

Thread view: 
Carmelo - 08 May 2005 03:53 GMT
Hi, for all
I have a problem- I made an applet
I want to read some files on the server where there is the applet
but for the first thing I need to scan all the directories avaible.
I use this code

File[] Cartelle;

String Path = getCodeBase().toString();

File dir = new File(Path);
// This filter only returns directories
   FileFilter fileFilter = new FileFilter() {
       public boolean accept(File file) {
           return file.isDirectory();
       }
   };

Cartelle = dir.listFiles(fileFilter);

When the program arrive here .... It stops to work because the acces is
denied
How can I to resolve ?
Thanks
Shorty - 09 May 2005 21:45 GMT
First, the applet runs on the client, not the server, so you will read
files from the client filesystem, not the server's.

In order to be able to access the filesystem, you will need to sign the
applet. Check the jarsigner utility in your JDK bin directory.

Good luck.

Antoine
Carmelo - 10 May 2005 00:26 GMT
Yes u are right but i need to read file on the server .. i want to show pics
and the user needs to select the pics
for this i need to read all the file in a directory
Shorty - 10 May 2005 09:08 GMT
Using the File.listFiles method, your applet can only list local
(client) files. If you want to scan a directory on the server, your
applet will need to get the list from the server. I'd say, the easiest
way would be a dynamic page (using PHP or a servlet) dans lists the
content of a directory (which can be passed as a parameter) and return
the list of files (with your own format that the applet knows how to
parse).
That way the applet can ask the servlet or PHP page for the listing of
a directory, parse it to get an array of file names, present it to the
user in a combo box or such, and when the user has chosen a file, get
the specific file through a regular HTTP request.
This of course is the simple way if all the files are in a single
directory on the server, and you don't need to navigate up and down
through directories.

Hope this helps


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.