Hi,
I want to send Image from J2ME to SERVLET. I am able to convert image into Byte Array, and send by Http POST.
I have coded as :
- From Mobile :
conn = (HttpConnection)Connector.open(url,Connector.READ_WRITE,true);
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
os.write(bytes, 0, bytes.length);//bytes = byte array of image
At servlet :
String line;
BufferedReader r1 = new BufferedReader(new InputStreamReader(in));
while ((line = r1.readLine()) != null)
{
System.out.println("line=" + line);
buf.append(line);
}
String s = buf.toString();
byte[] img_byte = s.getBytes();
Now d problem I found is, when I send Bytes from Mob App, some bytes are LOST , whose value is 0A and 0D-Hex ...
Exactly, Cr- Carriage Return & Lf- Line Feed...
It means, POST method OR readLine() not able to accept 0A & 0D value...
And so I come to know that, LOST bytes are 0A and 0D occurrence in image's byte array....
Any one have any idea, how to do this, or how to use any another method.....
Thanks
-Akash