Hi,
I am facing a challenge in J2ME code. When I execute following code on Nokia 6300 it produces service not supported.
i have executed same code on Noka 6100, N73 and 6120 Classic.
Can any guide me about the error. Please look in to the code
I receive error on Sage "2" (if(mHttpConnection.getResponseCode() != HttpConnection.HTTP_OK))
Code://////////////////// Source Code///////////////// private void connect() { InputStream ins = null; String s = new String() ; try { // Query the server and retrieve the response. mWaitCanvas.setMessage("Connecting..."); mHttpConnection = (HttpConnection)Connector.open(mURL, Connector.READ_WRITE,true); mStage = "1"; mHttpConnection.setRequestMethod(HttpConnection.GET); mHttpConnection.setRequestProperty("Connection", "close"); //mHttpConnection.setRequestProperty("User-Agent", ""); mStage = "2"; if(mHttpConnection.getResponseCode() != HttpConnection.HTTP_OK) { throw (new HTTPException(mHttpConnection.getResponseCode(), mHttpConnection.getResponseMessage())); //throw (new HTTPException(mHttpConnection.getResponseCode(), mHttpConnection.getResponseMessage())); } mStage = "2.5"; ins = mHttpConnection.openInputStream(); mStage = "3"; // Pull back the server's response. If a content length is not // specified, we'll just read 255 bytes. mWaitCanvas.setMessage("Receiving..."); ////////////////////////////////// // reading the response from web server character by character int ch; while( (ch = ins.read()) != -1 ) { s = s + (char) ch; } mStage = "4"; //////////////////////////////// // int contentLength = (int)mHttpConnection.getLength(); // if (contentLength == -1) contentLength = 255; // byte[] raw = new byte[contentLength]; // int length = ins.read(raw); // Clean up. ins.close(); mHttpConnection.close(); mStage = "5"; // Show the response to the user. //String s = new String(raw, 0, length); //mForm.networkResponse(s); httpResultListner.networkResponse(s); } catch (HTTPException ex) { try { if (ins != null) ins.close(); if (mHttpConnection != null) mHttpConnection.close(); } catch (IOException ignored) { } //mForm.networkException(ioe); // httpResultListner.networkException(); } catch (IOException ioe) { if (mCancel == false) { try { if (ins != null) ins.close(); if (mHttpConnection != null) mHttpConnection.close(); } catch (IOException ignored) { } //mForm.networkException(ioe); httpResultListner.networkException(ioe); } mCancel = false; } }

Reply With Quote

