| Reply | « Previous Thread | Next Thread » |
|
I am experiencing problems when testing the sun example "Session Handling in MIDP" on a nokia 6310i . This example makes use of "Set-Cookie" and "Cookie" headers to handle a session between a midlet client and a servlet server.
The server is on Internet. The client connects through GPRS. It runs O.K. using the emulator (Nokia Developper's suite v1.0) with the 6310i phone as a modem. But not on the real phone: a new session is opened at each connection. Source code can be found at : http://wireless.java.sun.com/midp/articles/sessions/ I had to make a modification to avoid StringArrayOutOfBoundException on the real phone, I replaced : mSessionIDCookie = cookie.substring(0, semicolon); with if (semicolon>0) mSessionIDCookie = cookie.substring(0, semicolon); else mSessionIDCookie = cookie; Can somebody guide me about how to use servlet's session handling with MIDP on 6310i ? Thank you |
|
Hi gerodol,
I'm having the same problem. I also used the semicolon fix you describe, but the problem prevails. I have found that when you send the cookie back to the server (via setRequestProperty), the 6310i truncates the session id by 12 bytes. This doesn't happen with the emulator. It looks as if there's a buffer problem in the setRequestProperty 6310i implementation. I am now trying to find a work around. I've tried re-writing the jsessionid cookie as part of the url request, but the server (in my case TomCat) doesn't recognise it. Keep this thread posted with any progress you make and I'll do the same. Perhaps someone from Nokia could comment? Regards. |
|
I finally found a workaround that seems to work;
On the server... String sid; session = request.getSession(false); if (session == null) // first connection? { session = request.getSession(true); // create sid = session.getId(); response.setHeader("x-sid", sid); } In the Midlet (HttpPoster/doSend() in the Nokia Sum example).. String url; String baseurl; public HttpPoster(String url) { this.url = url; this.baseurl = url; ... } private void doSend(String request, HttpPosterListener listener) { ... //after reading and writing streams, etc... for (int i=0;;i++) { String key = conn.getHeaderFieldKey(i); String value = conn.getHeaderField(i); if (key == null) break; if (key.equals("x-sid")) { String sid = conn.getHeaderField(i); url = baseurl+";JSESSIONID="+sid; // use this new one in future } ... } I used the loop to find the x-sid header rather than getting it by name. This seems to not truncate the value. Regards. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|