hahahaha doGet ou doPost agora piorou hahahahaha, vou te mandar os dois códigos, o da jsp e o servlet, ai é melhor para entender.
JSP
<%@page import="com.mysql.jdbc.ResultSetRow"%>
<%@page import="LogicaTbg.Tbg_Plano_Contas"%>
<%@page import="java.util.*"%>
<%@page import="org.apache.commons.beanutils.*"%>
<%@page import="java.sql.*"%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@taglib uri="http://displaytag.sf.net" prefix="display" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SiCasp</title>
<link rel="stylesheet" type="text/css" href="css/sicasp.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/displaytag.css" />
<%
response.setHeader("Cache-Control", "no-cache");
response.setIntHeader("Expires", 0);
response.setHeader("Pragma", "no-cache");
%>
</head>
<body>
<!--Aqui Começa a tela de Consulta-->
<div>
<form action="Servlet_Tbg_Plano_Contas" method="post">
<div class="conteudoAjusteTopo"></div>
<div class="titulo">
<table class="tituloConteudo">
<tr>
<td><div align="center">Plano de Contas - Consulta</div></td>
</tr>
</table>
</div>
<div class="conteudo">
<table class="tabelaConteudo">
<tr>
<td width="114"><div align="right"></div></td>
<td width="549"> </td>
</tr>
<tr>
<td><div align="right">Ano:</div></td>
<td>
<label for="ano"></label>
<input name="ano" type="text" id="ano" size="10" maxlength="4" autocomplete="off" style="font-size:11px"/>
</td>
</tr>
<tr>
<td><div align="right">Código:</div></td>
<td><label for="codigo"></label>
<input name="codigo" type="text" id="codigo" size="25" maxlength="11" autocomplete="off" style="font-size:11px"/></td>
</tr>
<tr>
<td><div align="right">Descrição:</div></td>
<td><label for="descricao"></label>
<input name="descricao" type="text" id="descricao" size="60" autocomplete="off" style="font-size:11px"/></td>
</tr>
<tr>
<td><div align="right">Tipo:</div></td>
<td><select name="tipo" id="tipo" style="font-size:11px">
<option value="%" selected="selected">Todos</option>
<option value="A">Analítico</option>
<option value="S">Sintético</option>
</select></td>
</tr>
<tr>
<td><div align="right">Grau:</div></td>
<td><label for="grau"></label>
<select name="grau" id="grau" style="font-size:11px">
<option value="%" selected="selected">Todos</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
</tr>
<tr>
<td><div align="right">Sistema Contábil:</div></td>
<td><label for="sistema_contabil"></label>
<select name="sistema_contabil" id="sistema_contabil" style="font-size:11px">
<option value="%" selected="selected">Todos</option>
<option value="O">Orçamentário</option>
<option value="F">Financeiro</option>
<option value="P">Patrimonial</option>
<option value="C">Compensado</option>
</select></td>
</tr>
<tr>
<td><div align="right">Natureza:</div></td>
<td><label for="natureza"></label>
<select name="natureza" id="natureza" style="font-size:11px">
<option value="%" selected="selected">Todos</option>
<option value="D">Devedora</option>
<option value="C">Credora</option>
</select></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
</table>
</div>
<div class="rodape">
<table class="rodapeConteudo">
<tr>
<td><div align="center">
<input type="submit" name="cadastrar" id="limpar" value="Cadastrar" />
<input type="submit" name="limpar" id="limpar" value="Limpar" />
<input type="submit" name="pesquisar" id="pesquisar" value="Pesquisar" />
<input type="submit" name="imprimir" id="imprimir" value="Imprimir" />
</div></td>
</tr>
</table>
</div>
<div class="rodapeTabela"></div>
</form>
</div>
<!--Aqui Termina a tela de Consulta-->
<!--Aqui Começa a tela de Resultado da Pesquisa-->
<div align="center">
<display:table name="${lista_plano_contas}" pagesize="10" export="true" requestURI="${Servlet_tbg_plano_Contas}">
<display:setProperty name="export.pdf" value="true" />
<display:setProperty name="export.xml" value="true" />
<display:setProperty name="export.csv" value="true" />
<display:setProperty name="export.xls" value="true" />
<display:setProperty name="export.pdf.filename" value="Plano_de_Contas.pdf" />
<display:setProperty name="export.xml.filename" value="Plano_de_Contas.xml" />
<display:setProperty name="export.csv.filename" value="Plano_de_Contas.csv" />
<display:setProperty name="export.excel.filename" value="Plano_de_Contas.xls" />
<display:setProperty name="basic.msg.empty_list">Não existem relatórios para exibição</display:setProperty>
<display:column property="idtbg_plano_contas" title="ID" sortable="true" headerClass="sortable"/>
<display:column property="tbg_ano_codigo_ano" title="ANO" sortable="true" headerClass="sortable"/>
<display:column property="codigo_plano_contas" title="CÓDIGO" sortable="true" headerClass="sortable"/>
<display:column property="tp_plano_contas" title="TIPO" sortable="true" headerClass="sortable"/>
<display:column property="sistema_contabil_plano_contas" title="SIS" sortable="true" headerClass="sortable"/>
<display:column property="natureza_plano_contas" title="NAT" sortable="true" headerClass="sortable"/>
<display:column property="nm_plano_contas" title="DESCRIÇÃO" sortable="true" headerClass="sortable" />
<display:column title="Excluir" paramId="idtbg_plano_contas" paramProperty="ID" url="Servlet_tbg_Plano_Contas"/>
</display:table>
</div>
<!--Aqui Termina a tela de Resultado da Pesquisa-->
<!--Aqui Começa a tela de Cadastro-->
<div style="display: none">
<form action="Servlet_Tbg_Plano_Contas" method="post">
<div class="conteudoAjusteTopo"></div>
<div class="titulo">
<table class="tituloConteudo">
<tr>
<td><div align="center">Plano de Contas - Cadastro</div></td>
</tr>
</table>
</div>
<div class="conteudo">
<table class="tabelaConteudo">
<tr>
<td width="114"><div align="right"></div></td>
<td width="549"> </td>
</tr>
<tr>
<td><div align="right">Ano:</div></td>
<td>
<label for="ano"></label>
<input name="ano" type="text" id="ano" size="10" maxlength="4" autocomplete="off" style="font-size:11px"/>
</td>
</tr>
<tr>
<td><div align="right">Código:</div></td>
<td><label for="codigo"></label>
<input name="codigo" type="text" id="codigo" size="25" maxlength="11" autocomplete="off" style="font-size:11px"/></td>
</tr>
<tr>
<td><div align="right">Descrição:</div></td>
<td><label for="descricao"></label>
<input name="descricao" type="text" id="descricao" size="60" autocomplete="off" style="font-size:11px"/></td>
</tr>
<tr>
<td><div align="right">Tipo:</div></td>
<td><select name="tipo" id="tipo" style="font-size:11px">
<option value="A">Analítico</option>
<option value="S">Sintético</option>
</select></td>
</tr>
<tr>
<td><div align="right">Sistema Contábil:</div></td>
<td><label for="sistema_contabil"></label>
<select name="sistema_contabil" id="sistema_contabil" style="font-size:11px">
<option value="O">Orçamentário</option>
<option value="F">Financeiro</option>
<option value="P">Patrimonial</option>
<option value="C">Compensado</option>
</select></td>
</tr>
<tr>
<td><div align="right">Natureza:</div></td>
<td><label for="natureza"></label>
<select name="natureza" id="natureza" style="font-size:11px">
<option value="D">Devedora</option>
<option value="C">Credora</option>
</select></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
</table>
</div>
<div class="rodape">
<table class="rodapeConteudo">
<tr>
<td><div align="center">
<input type="submit" name="cadastrar" id="limpar" value="Cadastrar" />
<input type="submit" name="limpar" id="limpar" value="Limpar" />
</div></td>
</tr>
</table>
</div>
<div class="rodapeTabela"></div>
</form>
</div>
<!--Aqui Termina a tela de Cadastro-->
</body>
</html>
Servlet
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ServletsTbg;
import DaoTbg.Tbg_Plano_ContasDao;
import LogicaTbg.Tbg_Plano_Contas;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
*
* @author Neto
*/
public class Servlet_Tbg_Plano_Contas extends HttpServlet {
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=iso-8859-1");
String recebeMetodoPesquisar = request.getParameter("pesquisar");
String recebeMetodoImprimir = request.getParameter("imprimir");
String recebeMetodoCadastrar = request.getParameter("cadastrar");
if (!recebeMetodoPesquisar.equals("")) {
String recebeAno = request.getParameter("ano");
if (recebeAno.equals("")) {
recebeAno = "%";
}
String recebeCodigo = request.getParameter("codigo");
if (recebeCodigo.equals("")) {
recebeCodigo = "%";
} else {
recebeCodigo = recebeCodigo + "%";
}
String recebeDescricao = request.getParameter("descricao");
if (!recebeDescricao.equals("")) {
recebeDescricao = "%" + recebeDescricao + "%";
} else {
recebeDescricao = "%";
}
String recebeTipo = request.getParameter("tipo");
String recebeGrau = request.getParameter("grau");
String recebeSistema_Contabil = request.getParameter("sistema_contabil");
String recebeNatureza = request.getParameter("natureza");
Tbg_Plano_ContasDao tbg_Plano_ContasDao = new Tbg_Plano_ContasDao();
List<Tbg_Plano_Contas> rs = tbg_Plano_ContasDao.getLista(recebeAno, recebeCodigo, recebeDescricao, recebeTipo, recebeGrau, recebeSistema_Contabil, recebeNatureza);
//ResultSet rs = tbg_Plano_ContasDao.getLista(recebeAno, recebeCodigo, recebeDescricao, recebeTipo, recebeGrau, recebeSistema_Contabil, recebeNatureza);
//RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
HttpSession sessao = request.getSession(true);
sessao.setAttribute("lista_plano_contas", rs);
request.getRequestDispatcher("/tbg_plano_contas.jsp").forward(request, response);
//request.setAttribute("results", rs);
//request.getRequestDispatcher("/tbg_plano_contas.jsp").forward(request, response);
//request.getRequestDispatcher("/tbg_plano_contas.jsp").forward(request, response);
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(Servlet_Tbg_Plano_Contas.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (SQLException ex) {
Logger.getLogger(Servlet_Tbg_Plano_Contas.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}