Pankti Desai 0 Newbie Poster

I am making a program in jsp servlet. There are three tables in database:
category , subcategory and items.
Their structure is like this ::
category 'A'
--> subcategory '1'
===> item 'i'
===> item 'ii'
===> item 'iii'
--> subcategory '2'
===> item 'iv'

category 'B'
--> subcategory '3'
===> item 'v'
===> item 'vi'
--> subcategory '4'
===> item 'vii'

category 'C'
.....

and so on.
I want to place 2 dropdown lists :: one which shows only category names n another
showing subcategory names..
the problem is, in subcategory dropdown i want only subcategories of the category i have
selected in first dropdown.
Example :: if i select category 'A' i want that second dropdown should display only
subcategory '1' and '2'.
any help regarding this will be appreciated.
Below is the code i have used for displaying category and subcategory dropdown in jsp page. but here all subcategories are displayed irrespective of which category name i have selected.

<form action="update_info.jsp" target="op1">
              <%
              Class.forName("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","root");
              Statement stmt=con.createStatement();
              String s="select Category_ID,Category_Name from category";
              ResultSet rs =stmt.executeQuery(s);
              %>
            Category Name : <select name="catname">

                <% while(rs.next())
                  {

                    %>
                    <option value="<%= rs.getString("Category_ID")%>">
                    <%= rs.getString("Category_Name")%></option>
                <% }
                    %>

            </select>
            <br/>

           <% String s1="select SubCat_ID,Subcat_Name from subcategory";
              ResultSet rs1 =stmt.executeQuery(s1); %>

            SubCategory Name : <select name="subcatname">

                <% while(rs1.next())
                  {

                    %>
                    <option value="<%= rs1.getString("SubCat_ID")%>">
                    <%= rs1.getString("Subcat_Name")%></option>
                <% }
                    %>

            </select> <br/> <br/>

             <input type="submit" name="submit" value="Go"/>   
             </form>