Pessoal,
Tenho o seguinte jsp:
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td align="left">
<a href=""><b> A iniciar</b></a>
</td>
</tr>
<tr>
<td align="left">
<a href="/SupplyWeb/Filtro?status=Em andamento"><b> Em andamento</b></a>
</td>
</tr>
<tr>
<td align="left">
<a href="#"><b> Finalizado</b></a>
</td>
</tr>
<tr>
<td align="left">
<a href="#"><b> Cancelado</b></a>
</td>
</tr>
</table>
O seguinte servlet:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String status = request.getParameter("status");
PrintWriter out = response.getWriter();
out.println("Status: " + status);
FiltroProjetos fazLogin = new FiltroProjetos(); //conecta a classe
String resultado = fazLogin.FiltroProjetos2(status);// passa o parametro e recebe a resposta
}
E a seguinte classe:
package model;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class FiltroProjetos {
private ConexaoMysql conexaoMysql;
public String FiltroProjetos2(String status){
String statusProjeto = "Em andamento";
conexaoMysql = new ConexaoMysql();
Statement state = null;
ResultSet rs = null;
try {
state = conexaoMysql.getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = state.executeQuery("Select nome from projeto where statusProjeto = '" + status + "'");
while (rs.next()) {
String nome = rs.getString("nome");
System.out.println("Nome:" + nome);
}
} catch(Exception erro) {
System.out.println("Erro ocorrido na classe FiltroProjetos: n" + erro);
} finally {
if(state != null){ //fechar os statments
try {
state.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return statusProjeto;
}
}
O problema é que vou passar o status pelo JSP, este será pego pela servlet que passará para a classe buscar no banco de dados e este resultado tem que parar lá no JSP para que ele formate os registros achados. Como faço para passar esses registros para o jsp?