Gera o arquivo c/ lista antiga

0 respostas
J

Olá gente,

minha aplicação tem que gerar um arquivo, através duma lista que pego do meu request assim:
List lista =(ArrayList)request.getSession().getAttribute("lista");
Até ai blz! Eu gero o arquivo c/ minha lista. Quando eu faço uma BUSCA por uma outra lista e mando gerar o arquivo, não tem jeito, só sai c/ a lista antiga!!! eu já tentei zerar tudo! Segue o que zero:
finally{
            request.getSession().removeAttribute("lista");
            request.removeAttribute("lista");
            lista = null;
            to_file = null;
            savePath=null;
            response = null;
            request = null;
        }
Código do download do arquivo:
/** DOWNLOAD DE ARQUIVO GERADO 
          * Pasta Arquivos fica no projeto WEB, dentro do WebContent 
          */
            InputStream is  = getClass().getClassLoader().getResourceAsStream("geraArq/gerado.txt");            
            
            if(is!=null){
             byte[] b = inputStreamToBytes(is);       
            
		ServletOutputStream out = response.getOutputStream(); 		                	
		              		                	 
		response.reset(); 
		response.setHeader("Content-Disposition", "attachment;filename=lista.txt");
		response.setContentType("Application/txt");
		response.setContentLength(b.length);
		                	 
		out.write(b); 
		out.flush(); 
		out.close();	
                b = null;               
            }
Métodos complementares, inputStreamToBytes e copy:
public static byte[] inputStreamToBytes(InputStream in) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		copy(in, out);
		return out.toByteArray();
    }//inputStreamToBytes
    
    public static void copy(InputStream in, OutputStream out) throws IOException {
		byte[] buffer = new byte[1024];
		try {
			int n = in.read(buffer);
			while (n > 0) {
				out.write(buffer, 0, n);
				n = in.read(buffer);
			}
		} finally {
			if (!(in instanceof ZipInputStream))
				in.close();
			if (!(out instanceof ZipOutputStream))
				out.close();
		}
    }//copy transforma em bytes o arquivo

Agradeço desde já!

Criado 24 de novembro de 2007
Respostas 0
Participantes 1