Netbeans - Imprimir contenido de tablas en mysql

 
Vista:

Imprimir contenido de tablas en mysql

Publicado por c4 (1 intervención) el 15/11/2019 06:12:52
Hola, estoy desarrollando un proyecto java web, con MVC y CRUD pero el único inconveniente que tengo es que no logro imprimir el contenido de las tablas, ya lo intente con JSTL y continuamente me tira un error 500, tengo importada la librería JSTL 1.2.2 pero nada.
Este es mi codigo:

la parte del index donde inicia la consulta:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<form>
   <select name="estado">
       <option  name="estado" value="nuevo" >Nuevo</option>
       <option  name="estado" value="usado" >Usado</option>
       <option  name="estado" value="arriendo" >En arriendo</option>
   </select>
   <select name="tipo">
       <option name="tipo" value="casa">Casa</option>
       <option name="tipo" value="apartamento">Apartamento</option>
       <option name="tipo" value="finca">Finca</option>
   </select>
   <select name="ciudad">
       <option name="ciudad" value="bogota">Bogota</option>
       <option name="ciudad" value="medellin">Medellin</option>
       <option name="ciudad" value="cali">Cali</option>
   </select>
   <button>
       <a href="inmuebleControlador?menu=buscar&accion=Listar">Enviar</a>
   </button>
</form>


El controlador donde se hace el proceso:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String menu=request.getParameter("menu");
        String accion=request.getParameter("accion");
        if(menu.equals("buscar")){
            switch(accion){
                case "Listar":
                    List lista=indao.listar(accion, menu, accion);
                    request.setAttribute("inmuebles", in);
                   break;
            }
        request.getRequestDispatcher("inmuebleMostrar.jsp").forward(request, response);
    }
}


el DAO donde se hace la consulta:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public List listar(String estado,String tipo,String ciudad){
   String sql="select * from inmueble";
   List<inmueble>lista= new ArrayList<>();
   try{
     con=cn.conexion();
     ps=con.prepareStatement(sql);
     rs=ps.executeQuery();
     while(rs.next()){
         inmueble in=new inmueble();
         in.setEstado(rs.getString(1));
         in.setTipo(rs.getString(2));
         in.setCiudad(rs.getString(3));
         in.setCodigo(rs.getString(4));
         lista.add(in);
         con.close();
     }
   }catch(Exception e){
 
   }
   return lista;
 
}

el jsp donde se deberian mostrar los datos:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <table>
            <thead>
            <th>Estado</th>
            <th>Tipo</th>
            <th>Ciudad</th>
            <th>Codigo</th>
            <th>Acciones</th>
            </thead>
            <tbody>
            <c:forEach var="in" items="${inmuebles}">
                <tr>
                    <td>${in.getEstado()}</td>
                    <td>${in.getTipo()}</td>
                    <td>${in.getCiudad()}</td>
                    <td>${in.getCodigo()}</td>
                    <td>
                        <a>Editar</a>
                        <a>Eliminar</a>
                    </td>
                </c:forEach>
                </tr>
            <foreach>
            </tbody>
        </table>
 
 
    </body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder