Reputation: 579
I know it is possible to change time variable using JavaScript or something else, but I try to do it using JSP-s, without reloading the whole page.
To be more specific my code is the following:
<%
for(int second = 0; second < 60; i++)
{
out.print(second);
try { Thread.sleep(1000); }
catch(InterruptedException e) { return; }
}
%>
...and it doesn't tick and show the time passed after every second. Instead, only after 60 seconds it shows that the time is over. So is it possible to show the 'second' variable after every second in JSP or can I use sockets to accomplish this? Thank you.
Upvotes: 1
Views: 93
Reputation: 48067
JSP code is executed server-side. So the JSP you implement in your question will take 1 minute to render and then print all the seconds at once. You'll need to utilize Javascript to dynamically update your page once it's loaded by the browser.
Upvotes: 0
Reputation: 943591
No.
JSP runs on the server and sends the output to the browser.
There is no way to get the output from JSP to change without either:
Upvotes: 1