×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    37

    session id sent to emulator client but not series 40 client

    Hi there,

    When new J2ME client from 7210 emulator http to server, the server sends session id obtained via encodeURL(...);

    However, when new J2ME client is from 7210 phone using same code for both client and server, the server does not send session id since it find session.isNew() returns false.

    I am using Sun's smartticket server (the session mechanism) for my app.

    Could somebody help, I have not got a clue for this problem? What behaviour from mobile phone or mobile network make server think the session is not new?

    Many thanks in advance.

    qmei

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    Does the session ID get put in the header?

    It may be that the WAP gatway in your "real" setup is not passing on all item of the header correctly. I presume that your emulated and real setups are not using the same gateway, is that so?

    Graham.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    37
    Hi Graham,

    Many thanks for your reply. The logic works like this,

    Client send a request to server (J2ME HTTP), the server (J2EE servlet) creates a session. If server finds the session is new, it sends session id to the client, otherwise not.

    After first contact, the client is supposed to receive the session id. If the client finds the session id exists in following logic, different route will be used.for processing.

    Now the problem is when mobile client initiates a contact (even after many hours since last contact with the server), the server always thinks the session it just created is not new, ie the server mistakenly thinks the session id already sent to the client. So no session id will be sent and received to/by the mobile client.

    However, if the code runs in 7210 emulator, all logic behaviour is normal.

    I am using J2ME Http, and I am writing Http headers myself. The phone is using GPRS service from UK O2. The emulator is doing internet only. This is all the difference I know. Still no clue to my problem.

    Kind regards,

    QMei, London

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    Hi QMei,

    First, I should say that I am not too familiar with the servlets framework... but I have some sample code from a Nokia document entitled "A Brief Introduction to Networked MIDlets" that uses servlet sessions. This does things slightly differently to you, I think... they use this code to create a new session:

    HttpSession session = request.getSession (false);
    if (session == null) {
    session = request.getSession (true);
    String requestURL = HttpUtils.getRequestURL (request).toString ();
    String rewrittenURL = response.encodeURL (requestURL);
    response.setHeader ("X-RewrittenURL", rewrittenURL);
    }

    So they never call session.isNew()... which makes me wonder if they think there is some problem with session.isNew()...?

    However, I don't think your problem is servlet related. The 7210 emulator seems to be a pretty close match for the real thing... the biggest difference in your two setups is the addition of a WAP gateway.

    I use Orange in the UK, and I find that my server always receives POSTs with a content-type of text/plain... even if I have set a different content-type when I built the header!! Other people report other changes to headers and content when the WAP gateway gets involved (on other networks).

    The only way to check this is to take a look at what's being received at each end... could you get the servlet to send the entire request (header included) back to the phone as text content, so that the phone can display it? Even if it isn't the gateway, seeing exactly what's in the request and response might give you a clue.

    If you don't mind sending me your app, I'd be happy to try it on my 6100 over Orange, to see if that's different.

    Graham.

Posting Permissions

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