Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.2k views
in Java FTP by (820 points)
I am wanting to create a ftp program running in an applet. I have the following code already but I get two errors when I run it. The same code runs fine as an application. Below is the code I have and the errors I get.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

import com.enterprisedt.net.ftp.*;

public class Didaftp extends Applet 
{
  public void init() 
  {
     FTPClient ftp = null;
       
     String host="192.168.0.3";
     String user="username";
     String password="password";

     try 
     {
        // set up client    
        ftp = new FTPClient();
        ftp.setRemoteHost(host);

         // connect
         ftp.connect();
            
         // login
         ftp.login(user, password);

         // set up passive BINARY transfers
         ftp.setConnectMode(FTPConnectMode.ACTIVE);
         ftp.setType(FTPTransferType.BINARY);
            
         String[] files = ftp.dir(".", true);
            
         for (int i = 0; i < files.length; i++)
         {
            System.out.println(files[i]);
         }
         ftp.get("C:/test.txt", "test.txt");
      }
      catch(Exception e)
      {
         System.out.println(e);
      }
   }
}


There errors:

Could not read property 'edtftp.log.level' due to security permissions
Could not read property 'edtftp.log.log4j' due to security permissions
java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.3:21 could not connect


Is therea way of getting round this problem?

3 Answers

0 votes
by (820 points)
Partly fixed my problem. I've created a policy for my applet and its cured the first 2 errors, but now I have a different error when trying to download the file from my ftp server to the c drive on a remote computer.

java.security.AccessControlException access denied(java.io.FilePermission c:\test.txt read)


Can anyone help with this problem pls.

Thanks in advance.
0 votes
by (162k points)
You need to give your applet permission to read the file by the looks.

Partly fixed my problem. I've created a policy for my applet and its cured the first 2 errors, but now I have a different error when trying to download the file from my ftp server to the c drive on a remote computer.

java.security.AccessControlException access denied(java.io.FilePermission c:\test.txt read)


Can anyone help with this problem pls.

Thanks in advance.
0 votes
by (820 points)
You need to give your applet permission to read the file by the looks.


I believe I have done this. I may have got it wrong in the policies tho, perhaps someone could point me in the right direction. Here is what I have:

grant signedBy "Me", codeBase "file: /home/me/public_html/classes/" {
permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute", signedBy "Me";
permission java.security.AllPermission;
};


Also I have chmod'd the file permissions to 777 in case that was the problem.

Categories

...