página index.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="WEB-INF/jspf/banco.jspf"%>
<!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>Controle de Patrimonio</title>
</head>
<body>
<table width="400" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>C&oacute;digo</td>
<td>Descri&ccedil;&atilde;o</td>
<td>Modelo</td>
<td>Acess&oacute;rios</td>
</tr>
<%
ResultSet res = null;
res = stm.executeQuery(
"SELECT * FROM tbl_itens");
String cod;
cod = res.getString("id");
boolean liga = true;
while (res.next()) {%>
<tr bgcolor="<%= ((liga = !liga)?"#EBEBEB":"") %>">
<td><%= res.getString("codigo")%></td>
<td><%= res.getString("descricao")%></td>
<td><%= res.getString("modelo")%></td>
</tr>
<% }
res.close();%>
</table>
</body>
</html>
página de erro
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page isErrorPage="true"%>
<%@page import="java.util.*"%>
<!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>Erro no Sistema</title>
<link href="css.css" rel="stylesheet" type="text/css" /
</head>
<body>
<h1>Problema no Sistema</h1>
<p><b>Favor Informar ao analista do Sistema o seguinte erro:</b></p>
<%= exception.getMessage()%>
</body>
</html>
página banco.jspf
<%@page language="java" import="java.sql.*"%>
<%@ page errorPage="erro.jsp"%>
<link href="css.css" rel="stylesheet" type="text/css" /
<%
response.setDateHeader("Expires", 0);
response.setHeader("Pragma", "no-cache");
if (request.getProtocol().equals("HTTP/1.1"))
response.setHeader("Cache-Control", "no-cache");
%>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/patrimonio","root","root");
Statement stm = con.createStatement();
%>
Erro gerado pelo sistema:
[code]
Problema no Sistema
Favor Informar ao analista do Sistema o seguinte erro:
Before start of result set [/code]