0 Replies Latest reply on Dec 11, 2012 4:38 PM by 979304

    Need help to access a web page using midlet to retrieve some informations

      Hi everyone i'm trying to access a web page using midlet to retrieve some informations in text format, the web page is [http://daviddurand.info/D228/?villes|http://daviddurand.info/D228/?villes] for my project.
      the problem is that i always get error 10049 in socket::open meaning no adresse could be found i tried IP adresse and still the same.
      i managed to recreate the same web page to test it on local and the surprise that it works fine but when accessing it online i have this error.
      i tried also to get the page i created on a webserver i own to try it saying that there might be security issues but the same error appears again. so help plz

      here is my code :

      package mobileapplication5;

      import java.io.*;
      import javax.microedition.io.*;
      import javax.microedition.lcdui.*;
      import javax.microedition.midlet.*;

      public class GetMidlet extends MIDlet {

      private Display display;

      String url = "http://dayaati.com/villes/index.php?villes";

      public GetMidlet() {
      display = Display.getDisplay(this);

      public void startApp() {
      try {
      } catch (IOException e) {

      System.out.println("IOException " + e);
      public void pauseApp() {   }
      public void destroyApp(boolean unconditional) {  }

      public void getBirthdayFromNameUsingGet(String url) throws IOException {
                HttpConnection httpConn = null;

                InputStream is = null;
                OutputStream os = null;

                try {

      httpConn = (HttpConnection)Connector.open(url);

      httpConn.setRequestProperty("User-Agent", "Profile/MIDP-2.1 Configuration/CLDC-1.1");
      httpConn.setRequestProperty("Content-Language", "en-US" );
      httpConn.setRequestProperty("Content-Type", "text/html; charset=iso-8859-1");
      httpConn.setRequestProperty( "Connection", "keep-alive" );


                int respCode = httpConn.getResponseCode();
                if (respCode == httpConn.HTTP_OK) {
                     StringBuffer sb = new StringBuffer();
                     os = httpConn.openOutputStream();
                     is = httpConn.openDataInputStream();
                     int chr;
                     while ((chr = is.read()) != -1)
                     sb.append((char) chr);

                     // Web Server just returns the birthday in mm/dd/yy format.
                else {
                     System.out.println("Error in opening HTTP Connection. Error#" + respCode);

                } finally {
                     if(is!= null)
                     if(os != null)
                if(httpConn != null)


      void getConnectionInformation(HttpConnection hc) {
      System.out.println("Request Method for this connection is " + hc.getRequestMethod());
      System.out.println("URL in this connection is " + hc.getURL());
      System.out.println("Protocol for this connection is " + hc.getProtocol());
      System.out.println("This object is connected to " + hc.getHost() + " host");
      System.out.println("HTTP Port in use is " + hc.getPort());
      System.out.println("Query parameter in this request are " + hc.getQuery());

      **Heeeeeeelp Please**