title: How to show related subcategory in drop down list based on the selection of category in 1st drop down list using servlet and jsp in netbeans?
body: <p>I am making a web application in java using netbeans and mysql. There are two tables in database "Categroy" and "SubCat". and there are entity classes and session beans to extract data from database. 
  There are two drop down lists in a jsp form. I want that when a category is selected in 1st drop down list, its category id is gone in servlet and from there, a list of only releated subcategories are shown in the 2nd drop down list. How I can get that? </p>
  
  <p>My JSP code is as under</p>
  
  <pre><code>    &lt;form action="&lt;c:url value='submit_site'/&gt;" method="POST"&gt;
      &lt;table border="0"&gt;
          &lt;tbody&gt;
                 &lt;tr&gt;
                  &lt;td&gt;&lt;label for="cat"&gt;Category&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt; 
                      &lt;select name="category"&gt;
  
                          &lt;c:forEach var="cat" items="${categories}"&gt;
                              &lt;option name="catId" value="${category.id}"&gt;${cat.id}. ${cat.catName}&lt;/option&gt;
                          &lt;/c:forEach&gt;
                      &lt;/select&gt; 
                  &lt;/td&gt;
              &lt;/tr&gt;   
              &lt;tr&gt;
                  &lt;td&gt;&lt;label for="SuCat"&gt;SubCategory&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;
                      &lt;select name="subcat"&gt;
                          &lt;option&gt;Select...&lt;/option&gt;
                          &lt;c:forEach var="subcat" items="${subCategories}"&gt;
                              &lt;option name="subId" value="${subcat.subId}"&gt;${subcat.subCatName}&lt;/option&gt;
                          &lt;/c:forEach&gt;
                      &lt;/select&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;
                      &lt;input type="submit" 
                             value="Submit"/&gt;
                  &lt;/td&gt;
                  &lt;td colspan="2"&gt;
                      &lt;input type="reset" 
                             value="Reset" /&gt;
                  &lt;/td&gt;
  
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>All categories from database are displayed in first drop down list but from the first drop down list the id of selected category is not getting into the servlet and subcategories are not shown in 2nd drop down. How can i get related subcategories in 2nd drop down? please guide me i am stucking in this from two weeks.</p>
  
  <p>I have searched on web but can't solve my confusion. There are javascripts for drop down list but i can't understand these scripts. Can i do that without using javascript cod?</p>