Search code examples
javaftpmvs

& becomes & during FTP to MVS


I am using a java library (edtftpj) to FTP a file from a web app hosted of a tomcat server to an MVS system.

The FTP transfer mode is ASCII and transfer is done using FTP streams. The data from a String variable is stored into an MVS dataset.

The problem is all the ampersand characters get converted to & . I have tried various escape characters including \& , ^& and X'50' (hex value), but none of it helped.

Anyone has any idea how to escape the ampersands please?


Solution

  • Nothing in the FTP protocol would cause this encoding behavior.

    Representing & as & is an XML based escaping representation. Other systems might use the same scheme, but as a standard, this is an XML standard encoding.

    Something in the reading of the data and writing of the data thinks it should be escaping this information and is doing the encoding.

    If anything on the MVS system is using Java it is probably communicating via SOAP with some other connector, which implies XML, which could be causing the escape sequence to be happening.

    Either way, the FTP protocol itself part is not part of the problem, ASCII transfer should only encode things like line endings, & is already a valid ASCII character and would not be affected. It is the MVS system that is doing this escaping if anything.

    Binary transfer is preferred in almost every case, since it doesn't do any interpretation or encoding of the raw bytes.