Web tier: servlets, JSP, Web frameworks: file from windows to unix

  1. file from windows to unix (2 messages)

    Servlet running in a unix machine wants to access a file in
    windows machine.can anyone suggest how to incorporate ftp command in servlet.
    Thanks in advance
  2. If the file(on the NT side) can be served up by a web-server, then just have the servlet open a socket or URLConnection and get it that way.

    If you really need to access it via FTP, then you have a couple of options. The easiest of which is to just create two batch files on the fly. One with the ftp comands, and one that executes the commands like below...

      PrintWriter fout = new PrintWriter(new FileOutputStream("ftp.in"));
      fout.println("open " + args[0]);
      fout.println("send " + args[1]);
      fout = new PrintWriter(new FileOutputStream("run.bat"));
      fout.println("ftp -s:ftp.in");
      String[] cmd = new String[3];
      cmd[0] = "command.com" ;
      cmd[1] = "/c" ;
      cmd[2] = "run.bat";

    Hope this helps
  3. Thanks.