Results 1 to 5 of 5
Thread: Object to Int casting
- 12-05-2008, 05:52 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 85
- Rep Power
- 0
Object to Int casting
In my java page I have
request.setAttribute("intLevel", intLevel); // intLevel is set as an Integer
and I am retrieving it in my jsp page using
int level = (int)request.getAttribute("intLevel");
I get a cast class exception, saying Object cannot be casted into Integer. Can you please help.
-
if it is returning an Integer, then can you just leave off the cast and let it auto-unbox to an int? Either that or call intValue() on the returned Integer object?
- 12-05-2008, 10:07 PM #3
I suppose that should work
Java Code:int level=Integer.parseInt(request.getAttribute("intLevel").toString);
- 12-06-2008, 09:43 PM #4
Member
- Join Date
- Sep 2008
- Posts
- 85
- Rep Power
- 0
Thanks guys, I will try those 2 options
-
Similar Threads
-
type casting
By alvations in forum New To JavaReplies: 1Last Post: 10-13-2008, 08:07 PM -
class casting
By vital parsley in forum New To JavaReplies: 1Last Post: 07-24-2008, 11:03 AM -
Casting problem
By John_28 in forum New To JavaReplies: 6Last Post: 05-14-2008, 12:29 PM -
Type Casting Help
By rhm54 in forum New To JavaReplies: 2Last Post: 02-07-2008, 01:06 PM -
Casting
By leebee in forum New To JavaReplies: 5Last Post: 08-10-2007, 01:24 PM
Bookmarks