Ola pessoal!
Já postei o meu problema anteriormente, mas mesmo com a ajuda da galera não estou conseguindo fazer isso. Acho que não expliquei direito e por isso estou postando novamente
Estou utilizando JSP
Coloquei o Vector na sessao da seguinte forma
Vector vetor = new Vector();
try
{
Produto produtoSelecionado = new Produto();
produtoSelecionado.setDados(
request.getParameter(“codProd”),
request.getParameter(“nomeProduto”),
request.getParameter(“txtQuantidade”),
request.getParameter(“txtQtdMin”),
request.getParameter(“txtPrecoVenda”),
request.getParameter(“txtPrecoCusto”));
vetor.addElement(produtoSelecionado);
HttpSession sessaoVector = request.getSession(true);
sessaoVector .setAttribute(“matriz”, vetor);
}
catch(Exception e)
{ }
Até aqui não ocorre erro algum!
PROBLEMA!!!
NÃO SEI COMO FAÇO PARA RECUPERAR O VECTOR DA SESSAO, POIS PRECISO USÁ-LO NOVAMENTE.
Eu fiz assim!
Mas está ocorrendo erro
<%
try
{
HttpSession sessaoVector = request.getSession(true);
Vector lista = (Vector)sessaoVector.getAtribute(“matriz”);
}
catch(Exception e)
{ }
if (lista.size() >= 1)
{
elementos = lista.elements();
if (elementos != null)
{
while(elementos.hasMoreElements())
{
Produto prod = (Produto)elementos.nextElement();
%>
<%
// if (codigo.equals(prod.getCodProd()))
// preco = prod.getCodProd();
}
}
}
%>
MAS OCORRE O SEGUINTE ERRO:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred between lines: 567 and 584 in the jsp file: /jsp/ContasPagar.jsp
Generated servlet error:
C:Tomcat 4.0worklocalhostccprjspContasPagar$jsp.java:846: Method getAtribute(java.lang.String) not found in interface javax.servlet.http.HttpSession.
Vector lista = (Vector)sessaoVector.getAtribute(“matriz”);
^
An error occurred between lines: 567 and 584 in the jsp file: /jsp/ContasPagar.jsp
Generated servlet error:
C:Tomcat 4.0worklocalhostccprjspContasPagar$jsp.java:851: Undefined variable or class name: lista
if ( >= 1)lista.size()