Hi,
I'm developing a mobile application for nokia x6. I am connecting to a server to read some data and i'm using http. From netbeans, when I run, it connects and displays the content of the link. However, when I run it on the phone, it fails with exception with message = -l;

One thing I noticed is that a message pops up asking you if you want the app to access the network but I do not see the part were the user. In short, the midlet is unable to connect to an external ip. What am I doing wrong. I created 3 sample midlets with the same reqult.

Below is some results:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package hello;

import java.io.IOException;
import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.*;

/**
* @author Administrator
*/
public class SecondExample extends MIDlet {
private Display display;
private String url =
"http://www.javacourses.com/hello.txt";
public SecondExample() {
display = Display.getDisplay(this);
}
/**
* startApp is invoked when
* the MIDlet is activated.
*/
public void startApp() {
//The specified URL is overridden
//in the descriptor
try {
downloadPage(url);
} catch(IOException e) {
// handle the exception
}
}
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);
is = c.openInputStream();
len =c.getLength();
if( len != -1) {
// Read exactly Content-Length bytes
for(int i =0 ; i < len ; i++ ){
if((ch = is.read()) != -1) {
b.append((char) ch);
}
}
} else {
//Read until the connection is closed.
while ((ch = is.read()) != -1) {
len = is.available() ;
b.append((char)ch);
}
}
t = new TextBox("hello again....",
b.toString(), 1024, 0);
} finally {
is.close();
c.close();
}
display.setCurrent(t);
}
/**
* Pause, discontinue....
*/
public void pauseApp() { }
/**
* Destroy must cleanup everything.
*/
public void destroyApp(boolean unconditional) { }

}


thank you,