Reputation: 14189
I have stored in two different attribute two integer value
session.setAttribute("passengers", new Integer(passengers))
session.setAttribute("luggages", new Integer(luggages));
but when I try to get them in a next request through
Integer passengers = (Integer) session.getAttribute("passengers")
Integer luggages = (Integer) session.getAttribute("luggages");
I get
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
Upvotes: 0
Views: 942
Reputation: 13844
you can use
int passengers = Integer.parseInt((String) session.getAttribute("passengers"))
int luggages = Integer.parseInt((String)session.getAttribute("luggages"));
Upvotes: 1