JSP Page HttpServletRequest getAttribute Typecasting

Posted by MontyBongo on Stack Overflow See other posts from Stack Overflow or by MontyBongo
Published on 2009-07-16T05:57:51Z Indexed on 2010/03/14 3:15 UTC
Read the original article Hit count: 432

Hi There,

Any ideas on the correct method of typecasting an Object out of a getAttribute request from a JSP page HttpServletRequest?

I have googled but it seems that the common solution is just sticking suppresswarnings in your code... Something I would very much like to avoid.

I currently have:

HashMap<String, ArrayList<HashMap<String, String>>> accounts = (HashMap<String, ArrayList<HashMap<String, String>>>)request.getAttribute("accounts");

And the complier is giving me this warning: Unchecked cast from Object to HashMap

Thanks in Advance!!

MB.

© Stack Overflow or respective owner

Related posts about java

Related posts about jsp