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?
My JSP code is as under
<form action="<c:url value='submit_site'/>" method="POST">
<table border="0">
<tbody>
<tr>
<td><label for="cat">Category</label></td>
<td>
<select name="category">
<c:forEach var="cat" items="${categories}">
<option name="catId" value="${category.id}">${cat.id}. ${cat.catName}</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td><label for="SuCat">SubCategory</label></td>
<td>
<select name="subcat">
<option>Select...</option>
<c:forEach var="subcat" items="${subCategories}">
<option name="subId" value="${subcat.subId}">${subcat.subCatName}</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit"
value="Submit"/>
</td>
<td colspan="2">
<input type="reset"
value="Reset" />
</td>
</tr>
</tbody>
</table>
</form>
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.
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?