title: retrieve value of arraylist in javascript in same page
body: <p>There is a JSP page in which i have an ArrayList variable. I need these arraylist values(txt1 and txt2) in script tag.I have tried lots of combinations and googling but didnot succeed.</p>
  
  <p>javascript function</p>
  
  <pre><code>function fun1()
  {   
     // how to get arraylist values      
  }
  </code></pre>
  
  <p>JSP page:</p>
  
  <pre><code> &lt;body&gt;
         &lt;%
             ArrayList&lt;String&gt; al= new ArrayList&lt;String&gt;();
             al.add("txt1");
             al.add("txt2");
  
             out.println("&lt;input type=text id=" + al.get(0) + "&gt;");out.println("&lt;br&gt;");
             out.println("&lt;input type=text id= " + al.get(1) + "&gt;");out.println("&lt;br&gt;");
             out.println("&lt;input type=button id=btn1  value=click onClick=fun1(); &gt; ");
         %&gt;
   &lt;/body&gt;
  </code></pre>
  
  <p>Thanks for reply</p>