michelpm1
michelpm1

Reputation: 177

Servlet ArrayList to JSP (Uncheked cast from Object to ArrayList)

i tried everything i saw, but without success, if someone can help with that, ooh man ..

The problem is that: I cant put a arraylist to jsp from servlet with success, eclipse shows me in JSP that:Uncheked cast from Object to ArrayList,

thats my Servlet Code

    filhoArray = dao.consultar_cpf(mae);
    request.setAttribute("filho", filhoArray);
    getServletConfig().getServletContext().getRequestDispatcher("/resultado-consulta.jsp").forward(request,response);

and JSP

Bebe bebe = new Bebe();

ArrayList<Bebe> list = (ArrayList<Bebe>) request.getAttribute("filho"); 

System.out.println(list);
out.print(list);

Upvotes: 3

Views: 1459

Answers (1)

wero
wero

Reputation: 33000

This is a warning that you are casting from a non-generic type to a generic type. In your special situation you can't avoid this cast and therefore you can silence the warning by writing:

@SuppressWarnings("unchecked")
ArrayList<Bebe> list = (ArrayList<Bebe>) request.getAttribute("filho"); 

Upvotes: 2

Related Questions