Ok, so i am quite new to JSP. Working on a big database project, and I'm left scratching my head here. The ugly code below calls the chemical name and chemical id properly, and links the chemical name to a page where the chemical with that id will be viewed, and it all works beautifully, EXCEPT, that only the first chemical is getting a link, the next ones down the line are just text. I'm sure it's simple, but i'd appreciate a point in the right direction, thanks :)
<DIV>
<%
String chem="";
qry1= "SELECT Chemicals.chemical_name, Chemicals.chem_id FROM plantandchemical, Chemicals WHERE plantandchemical.chem_id=Chemicals.chem_id and plant_id="+cno+" order by chemical_name";
ps = con.prepareStatement(qry1);
rs2 = ps.executeQuery();
while(rs2.next())
{ chem="<a href=viewchem.jsp?chem_id="+rs2.getString(2)+">"+chem+rs2.getString(1)+"</a>"+", ";
rs2.close();
%>
<DIV><%=chem%></DIV>