File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes FilesDownload from FTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "FilesDownload from FTP" Watch "FilesDownload from FTP" New topic
Author

FilesDownload from FTP

loganathan manickavasakam
Greenhorn

Joined: Jun 22, 2008
Posts: 5
Greetings!.

I have a big issue while downloading the files from FTP Server. The below is description of the project,
1) To connect ftp server
2) Pass the folder structure to FTP server
3) Found the folder and files within directory
4) List the files which is available in the folder
5) User can able to select the files
6) In the Pop up window have two options, Start download / Cancel.
7) If user selected "Start download" files gettting download to our Local PC.
---> Here, I have issues, if user select the start download action the files getting download to server only not for my machine (PC).
ALso i have used Socket to connect the client machine but i am not getting the connection from server to local port.
the below is my code
Socket ClientSocket = new Socket("localhost IP", Port).
the above line is getting error while running my code.
----
Can any one help me out to solve this issue.
(I need to download the files to my machine only not for server level. If any one have idea pls share me., it will be greate help). You can suggest me !!!.

Thanks,
Loganathan M
mspilogan@yahoo.com
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
Welcome to JavaRanch.

the files getting download to server only not for my machine
...
I need to download the files to my machine only not for server level.

I don't understand what these mean. You want to download the files from the server to the local machine, correct? What happens after you start the download?

Is there a particular reason you're not using a ready-made FTP library like Apache Commons Net?
loganathan manickavasakam
Greenhorn

Joined: Jun 22, 2008
Posts: 5
Greetings!..

thanks for your response..

Yes you are correct...I want to download the files from server to my local machine (from web).
After clicking the start download, the files are getting download to server only without any issues. Bur here i need to download to my local PC.


Yes, Actually i am using the library from Apache commons net. I am not sure about which jar file you are refereing from apache. If you dont mind please send me the link .

the below link i have used the jar file from apache.
http://www.informit.com/guides/content.aspx?g=java&seqNum=40
commons-net-1.0.0.jar

Thanks,
Loganathan M
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
"Downloading" generally means from a server to a client. So I'm not sure what you refer to when "the files are downloaded to the server fine", when really you want to download them to the local machine.

Where is this "Start Download" button - is this a desktop application running on the local machine?

I'd advise to get the latest version of Commons Net. Googling for "download apache commons net" should lead you to Apache's site.
loganathan manickavasakam
Greenhorn

Joined: Jun 22, 2008
Posts: 5
I am using servlet for downloading the files.

here is some more details,
1) Connecting FTP server by using servlet and bring pop up window
2) Popup window have list of Files, and files are displaying based up on the user selected from parent page.
3) Those files are available in server.
4) This pop up window (dev HTML page within servlet). Also have start download / cancel button.
5) If user clicks start download button, the startdownload will connect to FTP client and files are getting download.
6) Here we are passing two parameter (server path, local path). Local path i am giving my ip address but the server is not connecting to me local drive. This will give an error message called "Connection refused". If i am not passing any ip means this will take server drive as local drive and files are getting download in server itself.

7) thats why i user socket to connect the Client port as well as server port.
8) Server port is getting connected..
Scoket sServer = new Socket()
sServer.accept();
this is getting connected,,

but the same CLient socket
Socket sClient = new Socket("Ipaddress", port).
this is not connecting..

txs
logas
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
Now I get it - the web app FTPs a file from somewhere, and you then want that file downloaded to your local machine.

The easiest way to achieve this would be for the web app to store the file somewhere on the server, and then create a web app that has a link to that file.
loganathan manickavasakam
Greenhorn

Joined: Jun 22, 2008
Posts: 5
Yes.. Basically i am Lotus notes developer not for java. Could you please guide me or send me the sample code. I will intergtate it to my application and let you know the results.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
What code are you looking for - for generating a link on a web page? That's all that's left, really, since you said is file is stored on the server already.
loganathan manickavasakam
Greenhorn

Joined: Jun 22, 2008
Posts: 5
Yes I need the code for weblink.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
How do you generate the web pages?

Including something like <a href="http://www.server.com/myWebApp/myFiles/file.txt">download file</a> shouldn't be hard no matter how you do it, though. The file name would need to be dynamically inserted, of course.
[ June 23, 2008: Message edited by: Ulf Dittmer ]
mamun pratra
Greenhorn

Joined: Jun 17, 2008
Posts: 3
[ mamun, please don't post questions in an existing thread that are only tangentially related, if at all. That's called "hijacking", and frowned upon. Start a new topic instead. ]
[ June 24, 2008: Message edited by: Ulf Dittmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FilesDownload from FTP