Hi,
for (int i=1; (headerName = connection.getHeaderFieldKey(i)) != null; i++)
{
if (headerName.equalsIgnoreCase(SET_COOKIE))
{
Map cookie = new HashMap();
StringTokenizer st = new StringTokenizer(connection.getHeaderField(i), COOKIE_VALUE_DELIMITER);
if (st.hasMoreTokens())
{
String token = st.nextToken();
String name = token.substring(0, token.indexOf(NAME_VALUE_SEPARATOR));
String value = token.substring(token.indexOf(NAME_VALUE_SEPARATOR) + 1, token.length());
cookie.put(name, value);
cookieMap.put(name,cookie);
}
}
}
After retrieving the cookie I set it in the HTTP response.
Map cookie = (Map)cookieMap.get(cookieName);
httpResponse.addCookie(new Cookie(cookieName,(String)cookie.get(cookieName)));
and when i post the request in subsequent flow I set the cookies in the "Cookie" field of the header.
httpURLConnection.setRequestProperty("Cookie",getKookies(httpRequest.getKookies()));
where get cookies in a private method which returns a semicolon seperated list of cookies.
This works fine in IE and the session is maintained.
But the session is not maintained in Netscape or Mozilla.
Any pointers to the solution or to the flaws in the logic used would be helpful.
Thank you.
Moody