Hi All,

I have J2ME Client, Apache Tomcat Server 5.5. I am able to send file from J2ME Client to server upto certain limit. But once that limit crosses, i get OutOfMemory error. I did search on forum. One link. There were some more. They were talking about sending data in chunks.

I tried to get all data in ByteArrayOutputStream. - But when i write on dataOutputStream.write(byteArrayOutputStream.toByteArray()). Got OutofMemory error.

I tried sending one by one byte

while ((input.read(nextByte, 0, 1)) != (-1)) {
   daos.write(nextByte[0]); //daos is outputstream on httpconnection
But here one httpConnection is opened and then writing on that gives Symbian OS Error -4 (Not enough memory).

I tried setting "Transfer Encoding" to "Chunked" - But this gave response from server side : java.io.IOException: Invalid chunk header.

One way could be opening the HttpConnection again and again for each chunk of data and appending that on server side. So open httpconnection - Send Chunk - close connection. But is it advisable to open the httpconnection again and again and sending chunk of data. Or we have some way to open the connection once and then send the chunk of data.

Just for test i tried to send the stream of data in respose of servlet. It was able to send around 8MB of file to client (Didn't try more than that). So receiving file from server is no issue. But sending file is giving issue.

How to chunk data and send it to server?

Please guide or give some pointers which could help.