title: How to show the first value of dropdown list always on JSP for the first time when page is loaded?
body: <p>I am working on a JSP page and I need to show the selected value of dropdown list on that JSP page always. Below is my example - </p>
  
  <pre><code>&lt;p style="font-weight: bold"&gt;Limit&lt;/p&gt;
  &lt;select id="limit" name="limit"&gt;
      &lt;option value="10"&gt;10&lt;/option&gt;
      &lt;option value="20"&gt;20&lt;/option&gt;
      &lt;option value="50"&gt;50&lt;/option&gt;
      &lt;option value="100"&gt;100&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>For the first time when my page is getting loaded, I wanted to show 10 value as selected from the above dropdown list. Now if I select 20 from the above dropdown list and submit the form, I need to show 20 on that dropdown list by maintaining the state of the dropdown list always, so for that I used below code - </p>
  
  <pre><code>&lt;%
  String limit = request.getParameter("limit");
  %&gt;
  &lt;script&gt;
  document.getElementById("limit").value = '&lt;% out.print(limit); %&gt;';
  &lt;/script&gt;
  </code></pre>
  
  <p>But somehow, whenever I am loading my page for the first time, I always see blank field infront of <code>Limit</code> dropdown box and then if I select <code>20</code> from that dropdown list and submit the form again, then I can see <code>20 selected</code> in that dropdown list and if I select 50, and submit the form again, then again, I can also see 50 selected in that dropdown list. </p>
  
  <p>The only problem is for the first time when I load the page, it always shows blank field as selected value in the dropdown list which is not what I want, I want to select 10 for the first time automatically whenever the page is loaded first time.</p>