title: Read selected value of select box and pass it to jsp
body: <p>I'm pretty new to JSP, HTML, ... and have a question:</p>
  
  <p>I have a JSP and I'm trying to read a selected value from a HTML select box, e.g. with JavaScript:</p>
  
  <pre><code>&lt;form name="ListForm" action=""&gt; 
  &lt;select name="country" size="6"&gt;
  &lt;%
      String[] testArray = {"Germany", "Russia", "China", "Iran", "USA", "Israel"};
      for (int i = 0; i &lt; testArray.length; i++) {
  %&gt;
          &lt;option value=&lt;%=testArray[i]%&gt;&gt;
          &lt;%= testArray[i] %&gt; 
          &lt;/option&gt;
  &lt;%
      }
  %&gt;
  &lt;/select&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>This is the JavaScript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function getSelectedValue() {
          var e = document.getElementById("country");
          return e.options[e.selectedIndex].text;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Now I want to pass this String to another JSP:</p>
  
  <pre><code>&lt;% 
      String testVar = request.getParameter("country");
      session.setAttribute("varName", testVar); 
  %&gt;
  </code></pre>
  
  <p>But that doesn't work. Do you have a idea why?</p>