io utilizzerei completamente java

String stile = "background-color: ";
while (rs.next()) {
String colonna = rs.getString(1);
if (colonna.equals("campo giallo"))
stile += "yellow";
else if (colonna.equals("campo blu"))
stile += "blue";
else
stile += "green";
out.writeln("<td style=" + stile + ">testo</td>");
}