Hola a todos estoy usando display tag pero no en struts osea si nungun framework tab solo el JEE xD, bueno la cuestion esq no me sale aki dejo mi fuente y espero q alguen me pueda ayudar gracias de antemano.
ps: toy usando de ide netbeans 5.5.1 jdk 5 y display tab 1.2 recien la baje xD
Conexion.java //para la conexion
package sys.data;
import java.sql.*;
public class Conexion {
public static Connection cn() throws Exception{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
return DriverManager.getConnection("jdbc:odbc:cn","","");
}
public ResultSet consulta(String sql)throws Exception{
PreparedStatement pst=cn().prepareStatement(sql);
return pst.executeQuery();
}
}
Clase: Cliente .java
package sys.data;
import java.sql.ResultSet;
import java.util.*;
public class Cliente {
private int id;
private String nom;
private String dir;
ArrayList lista=new ArrayList();
public Cliente(){ }
public Cliente(int a,String b,String c) {
id=a;nom=b;dir=c; }
public int getId() {
return id; }
public String getNom() {
return nom; }
public String getDir() {
return dir; }
Conexion obj=new Conexion();
public ArrayList listar()throws Exception{
Cliente cl=new Cliente();
ResultSet rs=obj.consulta("select * from clientes");
while(rs.next()){
lista.add(new Cliente(rs.getInt(1),rs.getString(2),rs.getString( 3)));
}
return lista;
}
}
mi pag Pag1.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<table border="1">
<tr> <td><b>ID</b></td>
<td><b>Name</b></td>
<td><b>Name</b></td>
</tr>
<logic:iterate name="sys.data.Cliente" property="listar" id="var">
<tr> <td><bean:write name="var" property="id" /></td>
<td><bean:write name="var" property="nom" /></td>
<td><bean:write name="var" property="dir" /></td>
</tr>
</logic:iterate>
</table>
</body>
</html>