title: How to use request.getParameterValues?
body: <p>I'm trying to pass an array from one jsp page to another using a hidden form.</p>
  
  <p>Here is the relevant code of my jsp files.</p>
  
  <pre><code>&lt;td style="vertical-align: top;"&gt;&lt;button onclick="getPlayerNames()"id="generate"&gt;Generate&lt;/button&gt;&lt;br&gt;&lt;/td&gt;
  
  
  &lt;form id="playerNames" method="post" action="lineups.jsp"&gt;
  &lt;input type="hidden" id="players" /&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
      function getPlayerNames(){
            var selected = document.querySelectorAll("#selected-players &gt; tr &gt; td");
            var playernames = [];
            for(var i=0; i&lt;selected.length; ++i){
               //alert(selected[i].textContent);
               var num = (i-1)%6;
           if(num==0){
               playernames.push(selected[i].textContent);
           }
  
  
        }
        document.getElementById("players").values=playernames;
        alert(document.getElementById("players").values);
        document.getElementById("playerNames").submit();
  }&lt;/script&gt;
  </code></pre>
  
  <p>The alert message does show that the correct values are being placed in "players"</p>
  
  <p>Then on my lineup.jsp I have:</p>
  
  <pre><code>&lt;%String[] s = request.getParameterValues("players");
  System.out.println(s[0]);%&gt;
  </code></pre>
  
  <p>and I get a null pointer exception on the line with 'System.out.println(s[0]);'</p>