• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getParameter...not taking Long

 
Kingsley Mullers
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell me how you go about converting a long to string to allow for the below to run. i've tried the following but its complaining about incompatible type
long Complainantidnum =String.valueOf(request.getParameter("txtidnum"));

thanks
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.valueOf returns a String. To convert a String to a long, use
 
Kingsley Mullers
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks but i'm converting to a string.
and its giving me incompatible type
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kingsley Mullers:
long Complainantidnum =String.valueOf(request.getParameter("txtidnum"));

thanks


If you're converting to a String, why are you assigning it to a long ?
 
Alex Prawira
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that :

request.getParameter("txtidnum")

Return the long value ?

Try

Long myLong = request.getParameter("txtidnum")
String myString = myLong.toString()

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That wasn't what I was saying. String.valueOf() returns a String, but you are trying to assign it to a long. That's what's giving the error. What exactly are you trying to do ?
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getParameter() returns ALWAYS and ONLY String
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Alex. I thought your message was from the OP and was a response to my previous one. Having re-read the entire post I can see you were actually replying to the OP.

J
 
Shan Accent
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Kingsley Mullers ,

See the code
long Complainantidnum = String.valueOf(request.getParameter("txtidnum"));

You trying to store the string value to long variable without converting to long. What request.getParameter("txtidnum") statement actually returning ?

What type of value you want?
-------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic