iam having a jsp page Index.jsp which accept a only unicode string as its parameter and submit the form to Result.jsp. I need to maintain the cookie for the string entered by the user each time user enter the new string cookie value would be changed i have wriiten following code
In Index.jsp i have crated the Cookie
<%
Cookie ck= new Cookie("DNString",";");
response.addCookie(ck);
%>
and in the servlet i am trying to manage and set the cookie value each tim euser submits the form
private void fnSetCookieValues(HttpServletRequest request,HttpServletResponse response)
{
Cookie[] cookies=request.getCookies();
for (int i = 0; i < cookies.length; i++) {
System.out.println(""+cookies.length+"Name"+cookies[i].getName());
if(cookies[i].getName().equals("DNString"))
{
System.out.println("Inside if:: "+cookies[i].getValue()+""+cookies.length);
cookies[i].setValue(request.getParameter("txtIIDN"));
}
}
}
but the problem is that while getCookie() it doesnt give the DNString as the cookie but only shows 1NameJSESSIONID as System.out.println(“”+cookies.length+”Name”+cookies[i].getName()); statement output
but while looking througn browser like

it shows DNString as a cookie stored
can anyone figure out the problem and possible solution for it.
Thanks
The problem might be because of
;being the delimiter of cookie parameters.The value
";"added for the first time goes to the client with response header like this:The client sends back the cookie in the next request like this:
I think somewhere the parsing is failing because the value itself is delimiter.