Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP server -- FTP server, servlet

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have one HTTP server and one FTP server, but they both are located in different computers with different IP addresses. My question is : how the HTTP server fetch a file from FTP server and send back to client?
The servelet like this:
public void doService(....) {
// how to say the "address"
String address = "???/file.doc";
File file = new File(address);
out.sendback(file);
}
Thanks.
Edward
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, not that this is really a Servlet issue, but you COULD just send a redirect to the actual file on the correct server.
Alternatively, you could retrieve the actual file with some programming (think Jakarta Commons Net), and then return it just like you would any normal binary stream.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic