• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not SetInterval() is applicable for scriplet

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I want to display message for every five seonds in Server side using scriplet. For this, i have added below code.

<html>
<head>

<script type="text/javascript">
setInterval(function(){
show();
}, 5000);

function show(){

<%
System.out.println("Five Seconds");

%>
}
</script>
</head>
<body>

</body>
</html>






But it is showing the message "Five Seconds" only once. if we put alert() inside show() method, i displays alert message for every 5 seconds.
i.e.
<script type="text/javascript">
setInterval(function(){
show();
}, 5000);

function show(){

<%
System.out.println("Five Seconds");

%>
}
</script>



I dont now the reason. Please help me.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot mix JSP code with JavaScript. Please read this article to understand how JSP operates and why this is impossible.

If you want to communicate with the server via JavaScript, you'll need to use Ajax.

So, what is it that you are actually trying to accomplish?
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic