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>

So, few small changes, and it displays the chemical names in a horizontal row, making each name a separate link to a page with the chemical id (all of this on a page with a corresponding plant id). Just in case anyone was viewing this thread

<DIV> 
<%  String 
	marker= "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(marker);
        rs2  = ps.executeQuery();
	while(rs2.next())
		{  int id=rs2.getInt(2);
		    String chem=rs2.getString(1)+", ";
										
				 %>
<a href="viewchemical.jsp?chem_id=<%=id%>"><%=chem%></a>&nbsp;

<%  }    rs2.close(); %>	 

</DIV>

You better to move that database query to servlet