MIDP invalidating cookie

I have the following code :

privatevoid connect(){

String url = getAppProperty("SessionMIDlet.URL");

try{

// Query the server and retrieve the response.

HttpConnection hc = (HttpConnection)Connector.open(url);

if (mSessionIDCookie !=null)

hc.setRequestProperty("Cookie", mSessionIDCookie);

InputStream in = hc.openInputStream();

String cookie = hc.getHeaderField("Set-Cookie");

if (cookie !=null){

int semicolon = cookie.indexOf(';');

mSessionIDCookie = cookie.substring(0, semicolon);

}

int length = (int)hc.getLength();

byte[] raw =newbyte[length];

in.read(raw);

String s =new String(raw);

Alert a =new Alert("Response", s, null,null);

a.setTimeout(Alert.FOREVER);

mDisplay.setCurrent(a, mMainForm);

in.close();

hc.close();

}

catch (IOException ioe){

Alert a =new Alert("Exception", ioe.toString(), null,null);

a.setTimeout(Alert.FOREVER);

mDisplay.setCurrent(a, mMainForm);

}

}

and the servlet:

import javax.servlet.http.*;

import javax.servlet.*;

import java.io.*;

publicclass SessionServletextends HttpServlet{

publicvoid doGet(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException{

// Retrieve the session object corresponding to this request.

HttpSession session = request.getSession();

// Try to retrieve the user object from the session.

Object user = session.getAttribute("User-Information");

if (user ==null){

// Retrieve the user ID which is passed to us as a parameter.

String id = request.getParameter("user");

// Now look up the corresponding user information.

user = lookupUser(id);

// Put the user information into the session.

session.setAttribute("User-Information", user);

}

// Now process the request, using the user information we

// just looked up to customize our behavior. Write the

// response back to the client.

// For now, just compose a suitable reply message.

String message;

if (session.isNew())

message ="New session created: " + session.getId();

else

message ="Used existing session: " + session.getId();

// Send the message to the client.

response.setContentType("text/plain");

response.setContentLength(message.length());

PrintWriter out = response.getWriter();

out.println(message);

}

private Object lookupUser(String id){

// Most likely we would use JDBC[tm] to connect to a database,

// perform a query, package the results up as an object,

// and return that object. Most likely it would be a

// specific type, perhaps User, UserInformation,

// or UserPreferences.

returnnull;

}

}

I want to clear the cookie information. in the servlet i have added a method logout which i run and it has session.invalidate. Although it still stores the session id any ideas on how to clear the cookie i tried setting mSessionIDCookie to "" and null but no go.

[5577 byte] By [spear_arrowa] at [2007-10-2 20:35:38]
# 1
no one has the slightest idea? when i close the MIDP through sun's wireless toolkit emulator it creates a new session perfeclty.
spear_arrowa at 2007-7-13 23:18:51 > top of Java-index,Java Essentials,Java Programming...