You Are Here:

Community: Developer Discussion Boards

#1 Old problem with cookies on nokia 6310i ? - 2002-07-26, 13:01

Join Date: Mar 2003
Posts: 16
gerodol
Offline
Registered User
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
Reply With Quote

#2 Old RE: problem with cookies on nokia 6310i ? - 2002-07-29, 09:24

Join Date: Mar 2003
Posts: 3
acuth
Offline
Registered User
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.
Reply With Quote

#3 Old RE: problem with cookies on nokia 6310i ? - 2002-07-30, 08:26

Join Date: Mar 2003
Posts: 3
acuth
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia