title: using javascript variable for jsp
body: <p>my code is like this:</p>
  
  <pre><code>&lt;%
  ArrayList&lt;Item&gt; itemList = new ArrayList&lt;Item&gt;();
  itemList = projr.getObjects(projectID);
  if (itemList.size() != 0) {
  %&gt;
  
  &lt;script type="text/javascript"&gt;
  window.onload = function() {
  for(var i = 0;i &lt; &lt;%=itemList.size()%&gt;;i++){
      var azimuth=0;
      azimuth = &lt;%=itemList.get(i).getAzimuth()%&gt;;
  &lt;/script&gt;
  
  &lt;%
  }
  %&gt;
  </code></pre>
  
  <p>basically as you can see, due to certain reasons, i need to do the for loop within javascript. However, I cannot use the variable 'i' declared in javascript within the jsp&lt;%=%> tag. Hence, I was wondering if there could be any work arounds.</p>
  
  <p>I've tried to store 'i' as a cookie and try to retrieve it in the jsp by doing smth like:</p>
  
  <pre><code>azimuth = &lt;%=itemList.get(Integer.parseInt((request.getCookies())[0].getValue())).getAzimuth()%&gt;;
  </code></pre>
  
  <p>However, sadly this doesn't work. Also, I've thought of using hidden input fields to store 'i' but I don't think it would work as even if a did a request.getParameter(input name), i would not get anything as I have not submitted anything. Am I correct to say that?</p>
  
  <p>I would appreciate if any of you kind souls could help me out here =] </p>