Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session casting 1

Status
Not open for further replies.

mn12

Programmer
Dec 22, 2002
52
IL
Hi All,

I use the function getAttributes in my program.
This function return an object.
I want to convert it(the return value) to an int variable.
How can I do it?

Thanks,
mn12
 
If the object was originally an Integer object, then cast it :

Code:
Object o = session.getAttribute("abc");
Integer i = (Integer)o;
int ii = i.intValue();

or if it is a String or something, you'll have to force a conversion :

Code:
Object o = session.getAttribute("abc");
String s = (o +"");
int i = Integer.parseInt(s);

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top