• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

request.getParameter...not taking Long

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request.getParameter() returns ALWAYS and ONLY String
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
-------------------------
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic