This is the java code where I create the cookie.
Cookie c= new Cookie("pass", "abc");
response.addCookie(c);
And this is the JSP page where I am trying to retrieve the cookie details.
<%@ page import="javax.servlet.*, javax.servlet.http.*" %>
<% Cookie[] cookie=request.getCookies();
String passwd="pass";
for (int i = 0; i < cookie.length; i++) {
if(cookie[i].getName().equals("pass"))
{
passwd=cookie[i].getValue();
}
}
%>
<label for="pwd">Password : </label><input type="text" id="pwd" name="pass" value=<%=passwd%>></input>
Unable to retrieve application added cookie
This question is somewhat related to my problem though the answer dint help me.
Thank you for your comments. I had not set the path. For eg. If cookie is created in /xyz, it is not seen in /uvw. Now my code works fine.