I am try to develop a game with downlodable level for 7650 and i Must download files from the TOMCAT serverin the mobile divice but when i send POST HTTP the servlet read this and send the files but the device crash.
I have change the language to English and i use normal http connection not wap and not gprs but the Midlet crash!!
i have read that must use one other thread for use http is possible to have same free code with this use?
i post down my code:
private void doSend(String request, HttpPosterListener listener)
{
wasError = false;
byte[] arrayData = null;

try
{
connection = (HttpConnection) Connector.open(url);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-Length", Integer.toString(request.length()));

outputStream = connection.openOutputStream();

for (int i = 0; i < request.length(); ++i) // transmission
outputStream.write(request.charAt(i));
//Prova rete su 7650
if (outputStream != null)
outputStream.close();
//Fine prova rete

inputStream = connection.openInputStream(); // reception

long length = connection.getLength(); // DA RIVEDERE: perche non viene restituita ?
if (length > 0)
{
arrayData = new byte[(int)length];
inputStream.read(arrayData);
}
else
{
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
int ch;
while ((ch = inputStream.read()) != -1)
byteBuffer.write(ch);
arrayData = byteBuffer.toByteArray();
}

if (connection.getResponseCode() != HttpConnection.HTTP_OK)
{
wasError = true;
//DebugScreen.log("Error in HTTP connection receiving"
readyForInput = true;
}
}

catch (IOException e)
{
wasError = true;
readyForInput = true;
//DebugScreen.log("Error in HTTP connection sending and receiving"
}
finally
{
//closeStreams();
closeConnection();
}

if (!wasError)
{
Hashtable headers = parseHeaders(connection);
listener.receiveHttpData(arrayData,headers);
readyForInput = true;
}
}