Hi

Janardhanan, Ajith (AJANARDH) wrote:
In my ftplet, I am trying to output a list of strings to the ftp client
session. I am using the response.write() to do this. But looks like
there is a lack of flushing in the response object stream, I get
different output each time.
For eg, for the commands mkdir, I get the following ouput:

   ftp>mkdir testDir
       1111  Test1111
   ftp>mkdir testDir
       2222 Test2222
       3333 Test3333
       4444 Test4444
   ftp>mkdir testDir
       1111  Test1111
My ftplet code is below:

 public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request,
FtpReplyOutput response)
    throws FtpException, IOException {
try{
         response.write(new DefaultFtpReply(1111,"Test1111" ));
response.write(new DefaultFtpReply(2222,"Test2222" )); response.write(new DefaultFtpReply(3333,"Test3333" )); response.write(new DefaultFtpReply(4444,"Test4444" )); }catch(Exception ex){
           System.out.println(ex.toString());
        }

        return FtpletEnum.RET_SKIP;
    }

Is this a bug, or am I not using the proper method to do it. I
appreciate any help


This is not the correct way of doing this. First of all, you need to return one of the correct replies allowed for MKD:
501 Syntax error.
550 Not a valid file.
550 Already exists.
550 No permission.
250 Directory created.
550 Cannot create directory.

So, let's say you have created the directory the client asked for, and want to return your listing in your response, that would be something like: response.write(new DefaultFtpReply(250,"Test1111\nTest2222\nTest3333\nTest4444" ));

I just added a more convenient constructor for these cases, so if your running the very latest code you can use:

response.write(new DefaultFtpReply(250, new String[]{"Test1111", "Test2222", "Test3333", "Test4444"} ));

/niklas

Reply via email to