I try to run my first application using web access. Upon execution, N 6021 asks for network connection (I think this is on the Connector.open()) call,
Connector.open() returns a valid object, the casting to HttpConnection works fine
A nullpointerexception is thrown between the two textbox calls
I suspect a bug, or perhaps wrong configuration (however browser works fine)
Note, I am using gsm-data, not gprs for network communication.
Anybody used gsm-data communication for an applet with N 6021 ?
Here is the code extracts
protected void startApp() throws MIDletStateChangeException {
System.out.println("StartApp called");
try
{
downloadPage("http://www.javacourses.com/hello.txt");
}
catch(IOException e)
{
textbox.setString(textbox.getString()+"\nIOException");
display.setCurrent(textbox);
}
catch(NullPointerException ne){
textbox.setString(textbox.getString()+"\nNullPointerException");
display.setCurrent(textbox);
};
}
private void downloadPage(String url) throws IOException {
StringBuffer b = new StringBuffer();
InputStream is = null;
HttpConnection c = null;
TextBox t = null;
try {
long len = 0 ;
int ch = 0;
c = (HttpConnection)Connector.open(url);
textbox.setString(textbox.getString()+"\nc="+c);
display.setCurrent(textbox);
c.setRequestMethod(HttpConnection.GET);
is = c.openInputStream();
textbox.setString(textbox.getString()+"\nis="+is);
...

Reply With Quote

