Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

294
Vistas
In a table i have a list of files.If the file exists,the row bg color should be green or else red
<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>
<%}
%>

How can i do this to set the color of the row based on whether the file exist(green) if not row should be red.In this i am getting the details like file name and checking it if it exists or not but i dont know to proceed further

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I dont really know any JSP but whatever the language is, you should just set the color you want in your IF/ELSE block (dont think you really need the ELSE if you're in the while)

// ....
While (rs.next()) {
    String bgColor = "#00000";
    // ....

    if(file.exists()){
       bgColor = "#FFFF"
    }
    <tr style="background-color:<% bgColor %>;">
// ....
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda