Boa galera boa tarde a todos,
Assunto paginação:
Temos poucos recursos, certo?
Tentei utilizar as taglib ( display e Page ) sem sucesso ( caso algum amigo tenha um exemplo que possa me passar agradeço [email removido] ).
Recentemente consegui um código bem legal e fácil, nem tudo na vida são rosas... tem uma parte no código que ainda não resolvi e solicito aos amigos ajuda.
<style type="text/css">
<!--
body,td,th {
font-family: Verdana;
font-size: 10px;
color: #000000;
}
a:link {
color: #9966FF;
}
a:visited {
color: #9966FF;
}
a:hover {
color: #FF0000;
}
.style2 {color: #FFFFFF}
.style3 {color: #FF0000}
body {
margin-top: 0px;
}
-->
</style>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.sql.Date"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<%
String setor2 = (String) request.getParameter("grupo");
%>
<%
//Connection con = null;
Statement st = null;
ResultSet rs = null;
ResultSet rst = null;
try {
String setor = (String) request.getParameter("grupo");
String setor3 = (String) request.getParameter("grupo");
//String dsn = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/Atn/DB/RJJ0802.mdb";
//String usuario = "";
//String senha = "";
//String sql = "";
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
//Connection con = DriverManager.getConnection(dsn,usuario,senha);
String url="jdbc:mysql://localhost:3306/shelter";
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection(url, "root", "1272");
%>
<%
st = con.createStatement();
rst = st.executeQuery
//("Select * from Ramal");
//("Select Sum(IIf(CRJJ02.tipo = 0, 1, 0)) As efetuadas, Sum(IIf(CRJJ02.tipo = 1, 1, 0)) As recebidas From Ramal, CRJJ02 " +
//"where Ramal.ramal = CRJJ02.origem And grupo = '"+ setor3 +"' And data = date() ");
("select count(recebida) as recebidas, count(n_discado) as efetuadas From tb_ligacoes L, ramal R " +
"where R.ramal = L.ramal And R.grupo = '"+ setor3 +"' ");
while (rst.next()){
%>
<%
st = con.createStatement();
rs = st.executeQuery
// ("Select ramal, Sum(IIf(CRJJ02.tipo = 0, 1, 0)) As efetuadas, Sum(IIf(CRJJ02.tipo = 1, 1, 0)) As recebidas From Ramal, CRJJ02 " +
// "where Ramal.ramal = CRJJ02.origem And grupo = '"+ setor +"' And data = date() Group by Ramal.ramal");
("select R.ramal, count(recebida) as recebidas, count(n_discado) as efetuadas From tb_ligacoes L, ramal R " +
"where R.ramal = L.ramal And R.grupo = '"+ setor +"' Group by R.ramal ");
%>
<table width="100%">
<tr>
<td width="2%" height="125"> </td>
<td width="90%"><fieldset>
<legend>Sumário por ramal referente ao setor:<span class="style3"> <%=setor2%></span></legend>
<table width="100%">
<tr>
<td width="27%"> </td>
<td width="20%"> </td>
<td width="22%"> </td>
<td width="22%"> </td>
<td width="9%"> </td>
</tr>
<tr>
<td> </td>
<td><div align="center">Ligações Efetuadas</div></td>
<td><div align="center">Ligações Recebidas</div></td>
<td><div align="center">Ligações não atendidas</div></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><div align="center"><%= rst.getString("efetuadas") %></div></td>
<td><div align="center"><%= rst.getString("recebidas") %></div></td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%">
<tr bordercolor="#CCCCCC" bgcolor="#CCCCCC">
<td width="21%" bgcolor="#006699"><span class="style2"></span></td>
<td width="12%" bgcolor="#006699"><div align="center" class="style2">Ramal</div></td>
<td width="21%" bgcolor="#006699"><div align="right" class="style2">Ligações Efetuadas</div></td>
<td width="26%" bgcolor="#006699"><div align="right" class="style2">Ligações Recebidas</div></td>
<td width="20%" bgcolor="#006699"><span class="style2"></span></td>
</tr>
</table>
<%
while (rs.next()){
String grupo = rs.getString("ramal");
%>
<table width="100%">
<tr>
<td width="21%"><div align="center"></div></td>
<td width="12%"><div align="center"><% out.print ( "<a href='centroSetor4.jsp?grupo=" +grupo+ "' target=centro>"+grupo+"</a>"); %></div></td>
<td width="19%"><div align="right"><%= rs.getString("efetuadas") %></div></td>
<td width="26%"><div align="right"><%= rs.getString("recebidas") %></div></td>
<td width="22%"></td>
</tr>
</table>
<%
}
%>
<p> </p>
</fieldset>
</td>
<td width="8%"> </td>
</tr>
<p> </p>
<p> </p>
</table>
<%
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (rst != null) rst.close();
if (rs != null) rs.close();
if (st != null) st.close();
// if (con != null) con.close();
}
%>
</body>
</html>
Abraços galera.
Tenta reestruturar sua aplicação cara… mistrurar java com html fica muito ruim