I am writing an application in which I am using Http Connection to post data on a server. My App is working fine when I check it in emulator. My Webservice take too much time to generating responses and my emulator is also responding in a proper way. Somehow when I installed the app on the device, my app is posting data twice on the server. I have checked it... Does anyone have any solution on how to escape from this???
Here I am attaching my code of the sending request. I think the mobile app is sending another request when it reaches HTTP Time out, but I don't know what's the problem. Please Help me.
String param=
"function=OpenRecharge&LoginId="+SharedVariable.getUserInfo().getLoginID()
+"&BatchId="+SharedVariable.getSelectedProduct().getBatchID()
+"&SystemServiceID="+SharedVariable.getSelectedProduct().getSystemServiceID()
+"&ReferalNumber="+strMobileNo
+"&Amount="+strAmount
+"&FromANI="+fromMoNo
+"&Email="
+"&Checksum="+Checksum;
System.out.println("Final Parameter:\n"+param);
connection = (HttpConnection) Connector.open(url);
//Connector.open(param, strAmount, quit)
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
connection.setRequestProperty("Accept_Language","en-US");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
OutputStream out = connection.openOutputStream();
out.write(param.getBytes());
out.flush();
//System.out.println("Status Line Code: " + connection.getResponseCode());
//System.out.println("Status Line Message: " + connection.getResponseMessage());
is=connection.openDataInputStream();
int chr;
StringBuffer sb=new StringBuffer();
while ((chr = is.read()) != -1)
sb.append((char) chr);
System.out.println("Response===>"+sb.toString());
Can you serve up an answer with a place holder text like, "processing..." then after a delay have the web browser try again?