title: java method call from javascript in jsp page
body: <p>I am new to JSP,<br>
  I have method that contains loop and want to display value </p>
  
  <pre><code>&lt;%!
  private void getDemo() {
      for(int i=0; i&lt;10; i++) {
          setName("Val: " + i); %&gt;
          &lt;script language="javascript"&gt;
              var name = "&lt;%= getName()%&gt;";
              console.log(name);
          &lt;/script&gt;
      &lt;%!}
  }%&gt;
  &lt;%!
  String name;
  private void setName(String name) {
      this.name = name;
  }
  private String getName() {
      return this.name;
  }
  %&gt;
  </code></pre>
  
  <p><strong>Call</strong></p>
  
  <pre><code>&lt;script type = "text/javascript"&gt;
   window.onload=function(){&lt;%getDemo();%&gt;};
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Problem</strong><br>
  But when I see the console, It only display <code>Val: 9</code><br>
  How can I achieve all value?  I need Script code inside Java Code. Is it Possible? </p>