Accessing the database from JSP which is meant for display / view purposes is a bad practice. Put all your database access code in a servlet which would then set the retrieved data in a session or request scoped variable which would then be accordingly rendered in the JSP file. Look into JSTL (JSP standard template library) for a clean demarcation between display and logic.
Coming to your problem at hand, one thing which you can do is to set the 'display' style property of the option element to none for the elements which you don't want to render. Something like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Expires" content="0" /> <!-- disable caching -->
<title>Example</title>
</head>
<body>
<form action="#" id="frm">
<select name="selPrimary">
<option value="one">1</option>
<option value="two" style="display: none;">2</option>
<option value="three">3</option>
</select>
</form>
</body>
</html> The obvious disadvantage of this approach is that your site won't function when javascript is disabled since you would be needing its help for toggling the display style property of option elements.
You would attach an event handler to the onchange event listener of the primary select box. Based on it's value, you would iterate through the options of the secondary select box and make then visible / invisible based on some mapping which you would be having (populate second select box with 1.1, 1.2, 1.3 if the value selected in the first select box is 1 etc.). If all this seems confusing, you need to read up some good Javascript tutorials and things would start falling in place.