I don't see why this is a
JSP question. But anyway, why don't you just write one SQL statement that joins the two tables? And stick a where-clause in it while you're doing the change. It's much more effective (both in programming time and processing time) to have the database return only the data you need.
(Your current problem is that you are trying to use the "rs" ResultSet without setting it back to its start. But write the join-SQL instead of trying to do that.)