Skip to Content
0
Former Member
Jul 22, 2005 at 07:16 PM

JSPDynpage + set Cookie

68 Views

Iam trying to set a cookie in one JSP and trying to retrieve in another JSP of one JSPDynpage application..

<b>set.jsp</b>

<script language="javascript">

function createCookie()

{

<%

Cookie ck = new Cookie("name", "sap");

ck.setMaxAge(246060);

response.addCookie(ck);

%>

}

</script>

read.jsp

<script language="javascript">

function readCookie(){

<%

Cookie ck =null;

Cookie[] cookies = request.getCookies();

for(int i=0;i<cookies.length;i++)

{ ck = cookies<i>;

if(ck.getName().toString()=="name"){

out.println("Cookie:"+ck.getValue());

break;

}

}

%>

}

Iam not getting any errors..but not retrieving the stored cookie..Iam not sure if it setting it also.

Any hints??