Thank you very much for the response. Your solution works for mkdir.

I tried this solution for LIST command too. But I am running in to some
small issues. I am using the following command:

 response.write(new DefaultFtpReply(200, "Command successful\n
File1111\nFile2222\nFile3333") );
 return FtpletEnum.RET_SKIP;

The result is 

    ftp> ls
    200 Command PORT okay.
    200-Command successful
    200 File3333
    ftp> ls
    226 Closing data connection.
    200 Command PORT okay.

Any idea how to fix this would be greately appreciated.


-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Niklas Gustavsson
Sent: Saturday, July 14, 2007 5:30 PM
Subject: Re: Ftplet not working


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
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"} ));


Reply via email to