title: How to retrieve values in database and show in jsp select tag when another select tag is selected?
body: <p>Well in the project that I am working there's a database table containing the following fields :</p>
  <p><a href="https://i.stack.imgur.com/4r5Rv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4r5Rv.png" alt="The Database table:" /></a></p>
  <p>From the database table I want to show beds that's available in the ward that's not occupied when the ward is selected , then in bed select tag should show only available beds .</p>
  <p>The jsp form select tag code is :</p>
  <pre><code> &lt;div class=&quot;form-group&quot;&gt;
                              &lt;label for=&quot;course&quot;&gt;Ward No:&lt;/label&gt;
                                      &lt;div class=&quot;form-select&quot;&gt;
                                  &lt;select name=&quot;Ward&quot; id=&quot;course&quot;&gt;
                                      &lt;option value=&quot;0&quot;&gt;--Select Ward No---&lt;/option&gt;
                                      &lt;option value=&quot;ward1&quot;&gt;1&lt;/option&gt;
                                      &lt;option value=&quot;ward2&quot;&gt;2&lt;/option&gt;
                                      &lt;option value=&quot;ward3&quot;&gt;3&lt;/option&gt;
                                      &lt;option value=&quot;ward4&quot;&gt;4&lt;/option&gt;
                                      &lt;option value=&quot;ward5&quot;&gt;5&lt;/option&gt;
                                      &lt;option value=&quot;ward6&quot;&gt;6&lt;/option&gt;
                                      &lt;option value=&quot;ward7&quot;&gt;7&lt;/option&gt;
                                      &lt;option value=&quot;ward8&quot;&gt;8&lt;/option&gt;
                                      &lt;option value=&quot;ward9&quot;&gt;9&lt;/option&gt;
                                      &lt;option value=&quot;ward10&quot;&gt;10&lt;/option&gt;
                                      &lt;option value=&quot;ward11&quot;&gt;11&lt;/option&gt;
                                      &lt;option value=&quot;ward12&quot;&gt;12&lt;/option&gt;
                                  &lt;/select&gt;
                                  &lt;span class=&quot;select-icon&quot;&gt;&lt;i class=&quot;zmdi zmdi-chevron-down&quot;&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;/div&gt;
                                   &lt;/div&gt;
                                   &lt;div class=&quot;form-group&quot;&gt;
                              &lt;label for=&quot;bed&quot;&gt;Bed No:&lt;/label&gt;
                                      &lt;div class=&quot;form-select&quot;&gt;
                                          &lt;select name=&quot;Bed&quot; id=&quot;course&quot;&gt;     
                                      &lt;option value=&quot;0&quot;&gt;--Select Ward No---&lt;/option&gt;
                                      &lt;option value=&quot;bed1&quot;&gt;1&lt;/option&gt;
                                      &lt;option value=&quot;bed2&quot;&gt;2&lt;/option&gt;
                                      &lt;option value=&quot;bed3&quot;&gt;3&lt;/option&gt;
                                      &lt;option value=&quot;bed4&quot;&gt;4&lt;/option&gt;
                                      &lt;option value=&quot;bed5&quot;&gt;5&lt;/option&gt;
                                      &lt;option value=&quot;bed6&quot;&gt;6&lt;/option&gt;
                                      &lt;option value=&quot;bed&quot;&gt;7&lt;/option&gt;
                                      &lt;option value=&quot;bed8&quot;&gt;8&lt;/option&gt;
                                      &lt;option value=&quot;bed9&quot;&gt;9&lt;/option&gt;
                                      &lt;option value=&quot;bed10&quot;&gt;10&lt;/option&gt;
                                      &lt;option value=&quot;bed11&quot;&gt;11&lt;/option&gt;
                                      &lt;option value=&quot;bed12&quot;&gt;12&lt;/option&gt;
                                  &lt;/select&gt;
                                          
                                  &lt;span class=&quot;select-icon&quot;&gt;&lt;i class=&quot;zmdi zmdi-chevron-down&quot;&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;/div&gt;
                                   &lt;/div&gt;
  </code></pre>
  <p>So the question is how can I do this ?</p>
  <p>I am new java development and this is my first project , so please excuse if any silly mistakes are found.</p>
  <p>Thank you in advance for all helping out , its much appreciated.</p>