Como fazer um JSP abrir os dados do DB vindos da Servlet abaixo...
/*
* Pesquisar.java
*
* Created on 24 de Agosto de 2005, 09:28
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
/**
*
* @author Eduardo Bregaida
*/
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.Collection;
import model.OrdemServico;
public class Pesquisar extends HttpServlet{
public void doGet (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection ( "jdbc:odbc:bd"," "," ");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select * from chamado order by Numero");
Collection OrdemServico = new ArrayList();
while (rs.next()){
OrdemServico os = new OrdemServico();
os.setNumero(rs.getString("Numero"));
os.setsolic(rs.getString("solic"));
os.setdepto(rs.getString("depto"));
os.setdt_cham(rs.getString("dt_cham"));
os.seth_cham(rs.getString("h_cham"));
os.setmotivo(rs.getString("motivo"));
os.setdesc1(rs.getString("desc1"));
os.setdesc2(rs.getString("desc2"));
os.seth_inicio(rs.getString("h_inicio"));
os.seth_fim(rs.getString("h_fim"));
os.setdt_inicio(rs.getString("dt_inicio"));
os.setdt_fim(rs.getString("dt_fim"));
os.setprazo(rs.getString("prazo"));
os.settecnico(rs.getString("tecnico"));
os.setconcluido(rs.getString("concluido"));
os.setstatus(rs.getString("status"));
OrdemServico.add("os");
}
request.forward("/alteracao.jsp"); //Erro nessa linha...
}catch(Exception ex){
System.out.println(ex);
}
}
}
Página HTML q deve virar JSP
<html>
<head><title>OS</title></head>
<body bgcolor="#CC99FF">
<!--<form name="pesquisa" action="./mostrarSeuPedido">-->
<form name="pesquisa" action="<%= request.getContextPath() %>./pesquisar">
<INPUT type="hidden" name="actionType" value="inserirUsuario">
<p>Número: <font color="#CC99FF">.....</font><input type="text" name="Numero">
<font color="#CC99FF">....</font>Solicitante:<font color="#CC99FF"> .. </font><font color="#FFFFFF">
<input type="text" name="solic">
<font color="#CC99FF">.....</font> <input name="pesquisar" type="submit" value="Pesquisar">
</font> </p>
<p>
<table width="100%" border align="center" cellpadding="5" cellpacing="4">
<th align="center" colspan="5">Número</th>
<th align="center" colspan="5">Departamento</th>
<th align="center" colspan="5">Solicitante</th>
<th align="center" colspan="5">Técnico</th>
<th align="center" colspan="5">Status%</th>
<th align="centar" colspan="5"><input type="checkbox"></th>
</table>
<br>
<font color="#CC99CC">.............................................................................</font>
<input name="Excluir" type="Submit" value="Excluir">
<input type="Reset" value="Limpar">
<br>
<font color="#CC99FF">........................................................................</font>
</form>
</body>
</html>
Sou iniciante e estou com duvida... Já li diversos tutoriais, mas o conceito ta dificil de entrar...
