cookie problem

I want to convert a variable (sec) inside a javascript function (count) to a string and save it into a cookie inside the jsp, but jsp cannot recognize the variable. Can anyone help me?

<head>

<script language="JavaScript">

var sec=30;

function count(){

sec-=1;

window.status = sec;

if (sec==0){

window.alert("Time's up!!");

return;

}

countdown = setTimeout("count()",time_slot);

}

</script>

</head>

<body onload="count()">

...

<%

int second;

Cookie count_down =new Cookie("count_down_time",sec);

second = 60 * 60 * 24;

count_down.setMaxAge(second);

response.addCookie(count_down);

%>

...

</body>

how can I convert thesec into string and let jsp recognize it?

[1236 byte] By [KCPetera] at [2007-10-2 18:32:45]
# 1
You can't mix java/javascript code in this fashion.I don't quite get what you're trying to accomplish with cookies here, but you can create cookies in javascript just as easily as with java. http://www.quirksmode.org/js/cookies.html
evnafetsa at 2007-7-13 19:54:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks your help. I am doing countdown and check the sec in another jsp file.
KCPetera at 2007-7-13 19:54:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...