Click to See Complete Forum and Search --> : calling javascript with out any event


Avneesh
05-08-2003, 04:07 AM
Hi All,

I am facing a problem in the development of a system.
I want to call a javascript function from my JSP when a server side variable reaches a predefined value and i want to do it in HTML body.

can any one suggest me how do i call a javascript function with out any client event???

Gollum
05-08-2003, 05:02 AM
There's no direct way to call javascript from a server, but you have two options...

A: poll for changes...

<body onload="window.setTimeout('window.location.reload();',5000);">
...
</body>



B: or, if you know it's not going to be a long time (i.e. seconds), you can display your first page saying something like "Please wait, looking for results now..." plus javascript in the onload that immediately reloads, then at the server side when the request comes in, you can wait till you have everything before sending the response.