TOMCAT + Session

3 respostas
N

Pessoal,

estou desenvolvendo uma aplicação e precisei usar uma sessão, o problema é o seguinte a session no glassfish funciona direitinho, mas quando eu migro a aplicação para o TOMCAT a session para de funcionar.

Servlet

public class buscaServlet extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileNotFoundException, SQLException {
        HttpSession session = request.getSession(true);
        response.setContentType("text/html;charset=UTF-8");
        String endereco = request.getParameter("endereco");
        String estado =  request.getParameter("estado");
        String tipo = request.getParameter("tipo");
        PrintWriter out = response.getWriter();
        GerenciaPesquisa ger = new GerenciaPesquisa();
        ger.processaPesquisa(endereco, estado, tipo);
        try {
            List<Endereco> end = ger.getEndereco();
            RequestDispatcher rd = request.getRequestDispatcher("/lista_enderecos.jsp");
            session.setAttribute("sListaEnderecos", end);
            request.setAttribute("listaEnderecos", end);
            rd.forward(request, response);

        } finally { 
            out.close();
        }
    }

JSP

<body>
        <c:set value="10" var="pageSize"/>
        <c:choose>
            <c:when test="${empty param.s}">
                <c:set var="rowStart" value="1"/>
            </c:when>
            <c:otherwise>
                <c:set var="rowStart" value="${param.s}"/>
            </c:otherwise>
        </c:choose>
        <c:choose>
            <c:when test="${empty param.e}">
                <c:set var="rowEnd" value="${pageSize}"/>
            </c:when>
            <c:otherwise>
                <c:set var="rowEnd" value="${param.e}"/>
            </c:otherwise>
        </c:choose>
        <table>
            <tr bgcolor="#333333" class="contratos_titulo_tabela">
                <td>CPF/CNPJ</td>
                <td>Nome</td>
                <td>Abr.</td>
                <td>Logradouro</td>
                <td></td>
                <td>Compl.</td>
                <td>Bairro</td>
                <td>Cidade</td>
                <td>UF</td>
            </tr>
            <c:forEach var="endereco" begin="${rowStart-1}" step="1" end="${rowEnd-1}" items="${sessionScope.sListaEnderecos}" >

Alguém passou por isso ou sabe alguma solução?

Atenciosamente

Nilson

3 Respostas

N

Alguém tem alguma idéia???

kiko_lp_St_jimmy

Ja tentou substituir esse trecho:

<c:forEach var="endereco" begin="${rowStart-1}" step="1" end="${rowEnd-1}" items="${sessionScope.sListaEnderecos}" >

por algo similar a isto:

<c:forEach var="endereco" begin="${rowStart-1}" step="1" end="${rowEnd-1}" items="${sListaEnderecos}" scope="Session">

abs

N

Tentei isso, mas o scope não é reconhecido

Criado 11 de junho de 2011
Ultima resposta 13 de jun. de 2011
Respostas 3
Participantes 2