title: Accessing selected dropdown items using Java
body: <p>I have a dropdown which consist the language names. I am setting the value and displaying name of the dropdown by using a hashmap.</p>
  
  <pre><code> &lt;form action="TextTranslation" method="post" class="form" role="form" &gt;
          &lt;div class="row"&gt;
              &lt;div  id = "imageView" class="col-lg-8 center-block "&gt;
  
           &lt;div class="btn-group"&gt; 
           &lt;select name="country"&gt;
  
              &lt;% 
  
            Map&lt;String,String&gt; langCode = x.getCountryList();
             for( Object key :langCode.keySet() )
             {%&gt;
  
  
             &lt;option value="&lt;%=(String)key%&gt;"&gt;&lt;%=langCode.get(key) %&gt; &lt;/option&gt;
                &lt;% 
  
                System.out.println((String)key);
             }
  
             String name =  request.getParameter("country");
             request.setAttribute("code", name);
  
              %&gt;
  
  
  
          &lt;/select&gt;
      &lt;/div&gt;
          &lt;input type="submit" class= "btn btn-image" value="Translate"&gt;
  
                  &lt;a href="#search" class="btn btn-default bg-light-gray"&gt;Search Text&lt;/a&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
            &lt;/form&gt;
  </code></pre>
  
  <p>Values are passed correctly to dropbox as it print all the values in console. the set attribute is accessed in the particular servlet. But it gives a null value. Do you have any idea?Thank you in advance</p>
  
  <p><strong>UPDATED</strong></p>
  
  <pre><code>&lt;select name="country"&gt; 
      &lt;% 
         Map&lt;String,String&gt; langCode = x.getCountryList(); 
          for( Object key :langCode.keySet() ) 
            {%&gt;
                 &lt;option value="&lt;%=(String)key%&gt;"&gt;&lt;%=langCode.get(key) %&gt; /option&gt; 
                 &lt;% System.out.println((String)key); 
             } 
           String name = request.getParameter("country"); 
      %&gt; 
  &lt;/select&gt; 
  
  &lt;input type="hidden" name="code" value = &lt;%= name%&gt;/&gt; .
  </code></pre>
  
  <p>In the servlet I used,</p>
  
  <pre><code> request.getParameter("code");
  </code></pre>