×

Discussion Board

Results 1 to 12 of 12

Hybrid View

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    14

    j2me HttpConnection download fails

    Hi,

    I am simply trying to get an image from a cgi script in order to display it on my Nokia N90 phone.

    My code works through the S60 Nokia emulator but not on the deployed Nokia N90 Phone (I am using Eclipse + EclipseME + Nokia S60 SDK 3rd edition). The download image size is 0K.


    Could anyone help me please? This is an urgent issue for me...

    Here is an extract of my code :


    public void paint(Graphics g) {

    .....

    String imageData = getMapFromMapServer2(mapServerUrl+"/fast-cgi/mapservmode=map&map=/exec/applis/esgmap/current/mapserv/enville.map&mapext="+minX +"+"+minY +"+"+maxX+"+"+maxY+"&mapsize=352+290&layers=georoute4000k+georoute1000k+georoute500k+georoute250k+georoute100k+georoute50k+georoute20k+georoute5k+departements");



    ...




    The called function :

    public static String getMapFromMapServer2(String url) throws IOException {

    StringBuffer b = new StringBuffer();
    InputStream is = null;
    HttpConnection c = null;

    long len = 0;
    int ch = 0;
    c = (HttpConnection) Connector.open(url);
    is = c.openInputStream();

    //I know the size in advance
    len = 25389;


    for (int i = 0; i < len; i++)
    b.append((char) ch);

    is.close();
    c.close();
    return b.toString();
    }



    Many thanks in advance for help !!!!

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: j2me HttpConnection download fails

    hi,
    assuming you're using GET can you implement that via POST?
    it could be something with mobile data providers (lengthy urls) gateways,

    also add try/catch to your data fetching routine, check for response code from server, that helps with debuggin issues - we actually don't know what issue you're exactly getting on your device,

    btw: put fetching data route into separate thread outside of your paint method (so updates takes place after data is loaded without blocking ui thread),

    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    14

    Re: j2me HttpConnection download fails

    Indeed, the problem is located in the URL .

    If I only use one layer like department and remove the others (georouteX...), I can download and preview the image on the mobile phone.

    If the returned image contains several layers then my method algorithm can't download any data (seems that the inputstream is empty and my downloaded image size is 0).

    On the server side, it is MAPSERVER , a server that can buid maps.

    Any idea?

    Thanks

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    14

    Re: j2me HttpConnection download fails

    Are there any issues between the S60 Nokia phones whose N90 is part of and the MIDP HttpConnection API?

    It seems weird that I can download data fine through the S60 SDK emulator and not from the real Phone (I am using Orange provider with 3G subscription)..


    Please help..............

  5. #5
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: j2me HttpConnection download fails

    hi barbeNoire,
    what issues? are you getting some exception at all while trying to establish connection or no data is retrieved (-1)?
    I know issue with HTTP REDIRECT responses which is discussed somewhere on forum not working as expected (but can be workarounded), others are related to data carriers (length of urls in GET, urls encoding, custom headers in POST, etc) or general microedition limits (memory size/threads/releasing resources)
    regards,
    Peter

  6. #6
    Registered User
    Join Date
    Jul 2005
    Posts
    29

    Re: j2me HttpConnection download fails

    Hi barbenoir !

    I wonder how this code works at all (correctly) because you never read from that stream. So variable 'char ch' stays 0. I hope I am right, but i looked through the code more than three times.

    regards

    Michael

Similar Threads

  1. J2ME game demo download - to play and feedback
    By FrankFera in forum Mobile Java General
    Replies: 0
    Last Post: 2005-05-16, 06:55
  2. Free J2ME Web Site for download testing
    By arspeiser in forum Mobile Java General
    Replies: 10
    Last Post: 2004-03-31, 23:46
  3. drm object download fails
    By aurola in forum Digital Rights Management & Content Downloading
    Replies: 4
    Last Post: 2003-08-12, 11:28
  4. j2me application download
    By m_mogensen in forum Mobile Java General
    Replies: 1
    Last Post: 2002-08-22, 13:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •