First, never code business logic or data access logic in a jsp page.
Second, your code as it is posted should not even compile... You are looping over two ResultSets, rs and rs2 (line 26) which are declare nowhere. Moreover if I remember well you should call clear parameters method on pst2 at each iteration.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads