File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Connectiong to FTP site Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Connectiong to FTP site" Watch "Connectiong to FTP site" New topic
Author

Connectiong to FTP site

krishna dey
Greenhorn

Joined: Mar 11, 2008
Posts: 12
Hi all,
when i am opening ftp://mail.ftpsitename.com it is prompting for username and password. without disclosing the username and password to the user(i will pass both username and password using a link in jsp page), i want to connect to that ftp site. how can i do that?

please help me
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

If you create a link on a JSP page to the FTP site containing the username and password, the user will be able to see that information, either by reading the HTML source or when they roll over the link.
You could create a proxy, where your server application connects to the server, reads the index and presents a sanitized view to the user. That way you don't need to give credentials to the user.


[How To Ask Questions On JavaRanch]
krishna dey
Greenhorn

Joined: Mar 11, 2008
Posts: 12
Thanks for your reply,

instead of link i can use form tag and by submitting the form i can pass those parameter.that is not a problem. my problem is how to connect to that ftp server without disclosing the username & parameter.

Anyway How can i create proxy and connect to FTP server?
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Originally posted by krishna dey:

my problem is how to connect to that ftp server without disclosing the username & parameter.


Basically there are two ways/modes to get connected to an FTP server. One is anonymous which does not require a username/password credential. The other one is authorized access for which you should provide the credentials by some means. without which it is NOT possible at all.


Anyway How can i create proxy and connect to FTP server?


You don't need to create a proxy. There are plenty of proxy servers available. Just do a google search on that. Customize it according to your need and pass the credentials and save it so that it may not ask the user everytime to enter rahter it will remember those details and enter on behalf of the user when being asked everytime he tries to connect.

Hope this helps!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

Originally posted by Raghavan Muthu:
You don't need to create a proxy. There are plenty of proxy servers available.


I'm not talking about a proxy server, I'm talking about the proxy design pattern. Basically you write a servlet that contacts your FTP server with the credentials and returns the user a list of files. Then the user never has access to the credentials.
The problem with your form tag plan is that a clever user will try viewing the source, and get the credentials that way. Not to mention transmitting them in the clear across the internet is about as secure as posting them on a web page.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Originally posted by Joe Ess:


I'm not talking about a proxy server, I'm talking about the proxy design pattern.


Thank you Joe for correcting me by mentioning it explicitly .
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connectiong to FTP site