Hello,
Can someone please tell me how to ftp from a
servlet to a client. I have tried Sun and Apache's ftp client classes, sockets and URLConnection. In all cases the ftp just results in the file being "ftp'd" to the root directory of my account on my web host. The snippet of code I am currently using with a URL Connection is:
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URL url = new URL("ftp://user
wd@ftpServer/fileName;type=i"); // i.e. ftp location URL
URLConnection urlc = url.openConnection();
bis = new BufferedInputStream(urlc.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
int i;
while ((i = bis.read()) != -1) {
bos.write(i);
}
///////////////////////////////
Do I need an additional connection to the client? If so, can I get an example?