basically what I am trying create a servlet that will receive the bytes that are being sent from the MIDlet. I have pasted my function that is sending the bytes from the MIDlet so we can be on the same page.

If anyone can help please email me at <snipped>
Thank you in advance

// taking in the byte array holding the audio
void sendPostRequest(byte[] requestaudio)
{
HttpConnection hc = null;
DataInputStream dis = null;
DataOutputStream dos = null;


try
{
// Open up a http connection with the Web server
// for both send and receive operations
hc = (HttpConnection)
Connector.open(defaultURL, Connector.READ_WRITE);


// Set the request method to POST
hc.setRequestMethod(HttpConnection.POST);


// Send the audio user byte by byte
dos = hc.openDataOutputStream();
byte[] request_body = requestaudio;


for (int i = 0; i < request_body.length; i++)
dos.writeByte(request_body);


System.out.println("Packaging the bytes: " + request_body.length););



dos.flush();
dos.close();
//dis.close();
}
catch (IOException ioe) {}


finally
{
// Free up i/o streams and http connection
try
{
if (hc != null) hc.close();
}
catch (IOException ignored) {}


try
{
if (dis != null) dis.close();
}
catch (IOException ignored) {}


try
{
if (dos != null) dos.close();
}
catch (IOException ignored) {}
}
}

Edited 3 Years Ago by pyTony: fixed formatting

Hi there, Have you tested that this code perfectly sends data to the server? i doubt...

I would have tested it but I don't have the data...

Try checking it by accepting it with some simple server side script like php etc. if it works then move to servlet..

This article has been dead for over six months. Start a new discussion instead.