title: using jsp in javascript function
body: <p>I've searched for this but can't find anything.
  Please correct my question if it's incorrect english.</p>
  
  <p>This is my code:
  <strong>EDIT:</strong> The code is within my .jsp file!</p>
  
  <pre><code>    function drawChart() {
      var data = google.visualization.arrayToDataTable([
          ['Beoordeling', 'Stage Opleider', 'Student'],
  
          ['1', '1', '4'],
  
          &lt;% ArrayList &lt; Stelling &gt; alleStellingenLijst2 = new ArrayList &lt; Stelling &gt; ();
          alleStellingenLijst2 = (ArrayList &lt; Stelling &gt; ) request.getAttribute("stellingen");
          for (Stelling s: alleStellingenLijst2) {
              out.println("['1', '" + s.getDeStelling() + "' , '" + s.getDeWaarde() + "'],");
          } %&gt; ]);
      var options = {
          title: 'Laatste competenties',
          hAxis: {
              title: 'Score',
              titleTextStyle: {
                  color: 'green'
              }
          },
          vAxis: {
              title: 'Beoordeling nummer',
              titleTextStyle: {
                  color: 'green'
              }
          },
          // Allow multiple simultaneous selections.
          selectionMode: 'multiple',
          colors: ['#BEF781', 'green']
      };
      var chart = new      google.visualization.BarChart(document.getElementById('chart_div'));
      chart.draw(data, options);
  }
  </code></pre>
  
  <p>For some reason, it wont execute the code between the &lt;% %> (from the jsp).</p>
  
  <p>This page online: <a href="http://project-omega.appspot.com/grafieken.jsp" rel="nofollow">http://project-omega.appspot.com/grafieken.jsp</a>
  The google app engine logs say the error is on the last line of my page. It's a nullpointerexception.</p>
  
  <p>I have no idea what it means and I really hope someone can help me.</p>
  
  <p>Thanks a lot and sorry for my english.</p>
  
  <p><strong>EDIT</strong>
  The rendered output looks as follows</p>
  
  <pre><code>  function drawChart() {
      var data = google.visualization.arrayToDataTable([                                               
        ['Beoordeling', 'Stage Opleider', 'Student'],
        for (Stelling s : alleStellingenLijst2) {
          out.println("['1', '" + s.getDeStelling() + "' , '" + s.getDeWaarde() + "'],");       
      }  
    ]);
  </code></pre>
  
  <p>NEW CODE:</p>
  
  <pre><code> function drawChart() {
          var data = google.visualization.arrayToDataTable([
            ['Beoordeling', 'Stage Opleider', 'Student'],
  
            ['1', 1, 4],
  
            &lt;%
  
              ArrayList&lt;Stelling&gt; alleStellingenLijst2 =(ArrayList&lt;Stelling&gt;) getServletContext().getAttribute("stellingen");
              for (Stelling s : alleStellingenLijst2) {
                  out.println("['1', " + s.getDeStelling() + " , " + s.getDeWaarde() + "],");       
              }   
          %&gt; 
          ['2', 2, 2]
          ]);
  </code></pre>