<tr><th>s.no</th> <th>File name</th> <th>Date and time</th> <th>Show</th></tr> <% while(rs.next()){ String id=rs.getString(1); String name=rs.getString(2); String date=rs.getString(3); try{ File file=new File("C:\\Users\\Ragulprasath\\Desktop\\Register\\src\\main\\webapp\\uploaded\\"+name); if(file.exists()){ //what should put here } else{ //also here } } catch(Exception e){} %> <tr> <td><%=id%></td> <td><%=name%></td> <td><%=date%></td> <td><input type="button" onClick="location.href='view.jsp?msg=<%=name%>'" value="View the contents"/></td> </tr> <%} %>¿Cómo puedo hacer esto para establecer el color de la fila en función de si el archivo existe (verde) si no la fila debe ser roja? En esto, obtengo los detalles como el nombre del archivo y verifico si existe o no, pero no lo sé. para continuar
Realmente no conozco ningún JSP, pero sea cual sea el idioma, debe establecer el color que desee en su bloque IF/ELSE (no crea que realmente necesita ELSE si está en el tiempo)
// .... While (rs.next()) { String bgColor = "#00000"; // .... if(file.exists()){ bgColor = "#FFFF" } <tr style="background-color:<% bgColor %>;"> // ....