private List getFtp(String serverName, String login, String passwd) { FtpConnection ftp = null; List list = new ArrayList(); try { ftp = new FtpConnection(false,0); log("Connection anonyme à " + serverName); ftp.connect(serverName); if (ftp.login(login, passwd)) { ftp.changeDirectory("//usr"); log("Identification réussie !"); log("Le type de system est: " + ftp.getSystemType()); log("Le dossier courant est: " + ftp.getCurrentDirectory()); String files = ftp.listFiles(); String subDirs = ftp.listSubdirectories(); log("Fichiers:\n" + files); log("Sous dosssiers:\n" + subDirs); // on se contente de lister les fichiers présents StringTokenizer st = new StringTokenizer(files, ftp.lineTerm); while (st.hasMoreTokens()) { String file = st.nextToken(); list.add(file); } ftp.logout(); ftp.disconnect(); log("Disconnect et loggout."); } else { log("Connection impossible :/."); } } catch(Exception e) { e.printStackTrace(); try { ftp.disconnect(); } catch(Exception e2) {} } return list; } public String button1_action() { String server = (String) textFieldServer.getValue(); String login = (String) textFieldLogin.getValue(); String passwd = (String) passwordField1.getValue(); List list = getFtp(server, login, passwd); this.getSessionBean1().setList(list); return "case1"; }