title: Set a default value to a list in jsp that is stored in a Java Class
body: <p>I've been researching this one all day and cant seem to figrure it out.</p>
  
  <p>I have a JSP file called <em>Copy</em> which holds a drop down list of 10 elements. The user will be allowed to select 1-10 which will be the number of coppies they will print for a document.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;td&gt;
      &lt;select name="numCopiesList"&gt;
          &lt;option onclick="setSelectedCopyValue('1');" value="1"&gt;1&lt;/option&gt;
          &lt;!-- Add if statements to determine which is the default value --&gt;
          &lt;option onclick="setSelectedCopyValue('2');" value="2"&gt;2&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('3');" value="3"&gt;3&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('4');" value="4"&gt;4&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('5');" value="5"&gt;5&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('6');" value="6"&gt;6&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('7');" value="7"&gt;7&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('8');" value="8"&gt;8&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('9');" value="9"&gt;9&lt;/option&gt;
          &lt;option onclick="setSelectedCopyValue('10');" value="10"&gt;10&lt;/option&gt;
  &lt;/select&gt;
   &lt;/td&gt;
  </code></pre>
  
  <p>Within this JSP file I also have some javascript to try and help me.</p>
  
  <pre><code>function setSelectedCopyValue(&lt;%String value;%&gt;){
      &lt;%=ACCESSJAVACLASS.setAttribute("selectedCopyValue", value)%&gt;   
  }
  
  function getSelectedCopyValue(){
      return &lt;%=request.getParameter("selectedCopyValue")%&gt;; `
  }
  </code></pre>
  
  <p>Where it says <code>ACCESSJAVACLASS</code>, I am trying to reference my class nammed <code>AddAction</code> which is in charge of doing "stuff" when the user pushes an add button. This add button will refresh the form where everything is displayed on (which is why I'm trying to set this variable to be stored in a java class).</p>
  
  <p>Within my AddAction class I have:</p>
  
  <pre><code>private String selectedCopyValue = "1";
  public void setSelectedCopyValue(String selectedCopyValue) {
      this.selectedCopyValue = selectedCopyValue;
  }
  public String getSelectedCopyValue() {
      return selectedCopyValue;
  }
  </code></pre>
  
  <p>As well as a few other methods.</p>
  
  <p>What I'm trying to do is when the user clicks on a number on the drop down list, it will change the selectedCopyValue to the number they click. Then I want the drop down list to pull the selectedCopyValue and set the number they just selected as it's default. This way, if the user selectes 4 copies then presses add the GUI will be refreshed and when it comes back the list can repopulate with its showing/default value now set to 4 instead of 1 so the user will not have to re-select 4 another time.</p>