HELP Needed HttpConnection PROBLEM

Hi I'm a Newbie to the Blackberry development... I'm trying to read data from the URL through HttpConnection. Here it is my code. When I call through Simulator code, the following code does not run... System.out.println ("MDS getResponseCode" + c.getResponseCode ()); There is no exception too... Pls help what's wrong in my code...

Thanks in advance - Poy

import java.io.IOException;
import java.io.InputStream;
java.lang.String import;
Import javax.microedition.io.Connector;
Import javax.microedition.io.HttpConnection;
Import net.rim.device.api.ui.Field;
Import net.rim.device.api.ui.FieldChangeListener;
Import net.rim.device.api.ui.UiApplication;
Import net.rim.device.api.ui.component.ButtonField;
Import net.rim.device.api.ui.component.LabelField;
Import net.rim.device.api.ui.container.MainScreen;

Main class
SerializableAttribute public class HttpCxn extends UiApplication {}

Starting point
Public Shared Sub main (String [] args) {}
HttpCxn httpCxn = new HttpCxn();
httpCxn.enterEventDispatcher ();
}

Initial screen of calls
public HttpCxn() {}
pushScreen (new HttpCxnScreen());
}

}

class HttpCxnScreen extends form {}

Declare my initial variables

ButtonField submitButton = new ButtonField ("Submit", ButtonField.CONSUME_CLICK);
HttpCxnScreen screen = this;

Main screen, including the entries for the character/server names
public HttpCxnScreen() {}

Create the label of title for the main screen
LabelField mainTitle = new LabelField ("HTTP CONNECTION", LabelField.ELLIPSIS
| LabelField.USE_ALL_WIDTH);
Set title to the top of the label
setTitle (mainTitle);
Add other elements to the form

Add (submitButton);

Create the feature of the "submit" button
submitButton.setChangeListener (new FieldChangeListener() {}

' Public Sub fieldChanged (field field, int context) {}
Thread postnameThread = new Thread (new ServerConnection());
postnameThread.start ();
}

});

}

http connection class
ServerConnection class extends Thread {}

String url = ""http://172.24.30.27: 9091/demo/index.jsp;deviceside=false ";"

Method called by the Send button
public ServerConnection() {}
System.out.println ("test");
}

public void run() {}
C HttpConnection = null;
InputStream is = null;
Response string;
int rc;

try {}
StringBuffer buffer = new StringBuffer();
System.out.println ("URL" + URL);
c = (HttpConnection) Connector.open (url);
System.out.println ("AZtest" + c); My debugger not crossed this line
Get the response code is open the connection,
Send the request and read HTTP response headers.
The headers are stored until asked.
System.out.println ("MDS getResponseCode" + c.getResponseCode ());
RC = c.getResponseCode ();
System.out.println ("CHECK MDS" + rc);
If (rc! = HttpConnection.HTTP_OK) {}
System.out.println ("HTTP_OK" + RC);
throw new IOException ("HTTP response code:" + rc);
}

is = c.openInputStream ();

Get the ContentType
The string of type = c.getType ();

The length and process data
int len = (int) c.getLength ();
If (len > 0) {}
real int = 0;
int BytesRead = 0;
data Byte [] = new ubyte [len];
While ((bytesread! = len) & (real! = - 1)) {}
real = is.read (data, bytesread, len - bytesread);
bytesRead += real;
}
} else {}

int ch;

While ((ch = is.read (())! = - 1) {}
ch = is.read ();
buffer. Append ((Char) ch);
}
response = buffer.toString ();

}
} catch (Exception e) {}

e.printStackTrace ();

}
}
}
}

This message can help.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for

  • Pinned tabs are not visible.

    After I pin a tab in ff29, she disappears to the left of the row of tabs. I see a grey box blank where the pinned tabs were visible in ff28.

  • Satellite R830 - FN keys not working not

    Hello I have a laptop model * R830 *, but unfortunately the FN keys does not workI hope you help me With gratitude and thanks in advance* Fahmi

  • Equium A60 stops automatically after 10 min

    My laptop TOSHIBA Equium A60, after 10 minutes of work it disconnects because it seems to become very hot, even if the fan is working? How can I solve this problem

  • cvicc core dump

    Hi all I just set up a new production machine and the last cvi for linux runtime is installed. If I compile a program white int main (void) {return 2 ;} it works fine.} But a simple prog like this immediately main dumps: #include int main (int argc,

  • WRE54G V3 - Web: gateway no response

    I configured my WRE54G, following the instructions and moved in my living room and confirmed that the link linght has turned blue.  Since my iPhone wif' are and my Nokia N97, we now see a signal of 100%, up from 45 percent before installing the expan