This discussion is archived
1 Reply Latest reply: Aug 16, 2012 4:19 PM by EJP RSS

How to  return ftp connection object EJB Session bean to Client

956146 Newbie
Currently Being Moderated
hi all,

EJB Session bean code-server code

public final FTPClient getDetails(String serverip , String userName , String password) throws RemoteException
FTPClient ftp = new FTPClient();

                    reply = ftp.getReplyCode();
                    System.out.println("reply code is ==="+reply);
                    // ftp.enterLocalPassiveMode();
                         catch (Exception e)
                              //System.err.println("Unable to disconnect from FTP server after server refused connection. "+e.toString());
                         throw new Exception ("FTP server refused connection.");
                    System.out.println("Connected to " + ftpHost + ". "+ftp.getReplyString());

                    if (ftp.login(ftpUserName.toString().trim(), ftpPassword.toString().trim()))
                         //return false;
                         System.out.println("if part ftp connected..........");
                         //return false;
                         System.out.println("Else part ftp connected..........");

return ftp;

Client program code

Welcomehome home = (Welcomehome) PortableRemoteObject.narrow (ref, Welcomehome.class);
               Welcome wel = (Welcome)home.create( );
               System.out.println("wel obj is "+wel);
          FTPClient ftp=(FTPClient) wel.getDetails("xxx","xxxx","xxxxx");

                    System.out.println("ftp connected in client");
                    System.out.println("ftp not connected in client");

1. client ftp objects is not connected. to return server program FTPclient object to Client program ftpclient.

kindly tell me how to return server program ftpclient objects to client program FTP object refernce.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points