• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with converting java.lang.Object to java.lang.String[solved]

 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not able to cast Object class to String class. Object class is from session object...I tried with static String.valueOf(Object)...it is supposed to return string but returns int....

[/CODE]
[ January 06, 2006: Message edited by: Raghavan Chockalingam ]
 
Sameer Damle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just check the return type of your getMemberId(userName) method........

i think it must be int.... and you are returning that value in a String variable...
 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the member function of MemberBean class
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not able to cast Object class to String class.


You're not casting an Object to a String, you're trying to use an int where a String is required. Try

memberId = new Integer(memberBean.getMemberId(userName)).toString();

The line

String userName = String.valueOf(session.getAttribute("userName"));

could be written as

String userName = (String) session.getAttribute("userName");

but it should work as it is.
 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sameer was right, I was trying to store a return int variable in a String variable which I recognized now...
earlier, it was...


Thanks to all of your help guys...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic