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.
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:
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.