I am developing a java web application in NETBEANS and I have a query which shows only numeric values, when I execute my query it shows them in an organized table, everything works perfectly.
What I want to do are 3 "IF" conditions with the values that I pull from my Database:
- If the values are less than 50 the values are colored red.
- If the values are greater than 50 but less than 95, they are colored orange.
- If the values are greater than 96, they are colored green.
It is the final part of my development and your help would really help me, thank you very much.
I leave the code of my query below. The rs.getString()
are the values of the query.
<%
consulta conexion = new consulta ("jdbc:oracle:thin:@localhost:1521:XE","pasaportes","oppasaportes");
String consulta = "SELECT DELEGACION, id_delegacion, CONTRATO , prerequisitos_tecnologicos, equipamiento, sistema_operacion, privilegios, capacitacion, citas FROM delegaciones";
ResultSet rs = conexion.ejeSelect(consulta);
ResultSetMetaData rsmd = rs.getMetaData();
int col= rsmd.getColumnCount();
for(int k=1;k<=col;k++){
%>
<td><h9> <%= rsmd.getColumnName(k) %></h9></td>
<%
}
%>
</tr>
<%
while(rs.next()){
%>
<tr>
<td><h6><%= rs.getString(1) %></h6> </td>
<td><h6><%= rs.getString(2) %></h6> </td>
<td><h6><%= rs.getString(3) %></h6> </td>
<td><h6><%= rs.getString(4) %></h6> </td>
<td><h6><%= rs.getString(5) %></h6> </td>
<td><h6><%= rs.getString(6) %></h6> </td>
<td><h6><%= rs.getString(7) %></h6> </td>
<td><h6><%= rs.getString(8) %></h6> </td>
<td><h6><%= rs.getString(9) %></h6> </td>
</tr>
<%
}
%>
I think it is not very good to use java code in the views but rather to send objects to the views and handle them through JSTL. But I'll build on the code you've already raised in your question.
I assume that what you want to do is row by row, there you decide which rows you are interested in painting. Note that to make numerical comparisons you must obtain the data as "getInt" not as "getString".
Cheers!