This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes request.getParameter...not taking Long Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "request.getParameter...not taking Long" Watch "request.getParameter...not taking Long" New topic
Author

request.getParameter...not taking Long

Kingsley Mullers
Ranch Hand

Joined: Jan 14, 2005
Posts: 48
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

Joined: Aug 05, 2005
Posts: 3742
    
  16
String.valueOf returns a String. To convert a String to a long, use


Joanne
Kingsley Mullers
Ranch Hand

Joined: Jan 14, 2005
Posts: 48
thanks but i'm converting to a string.
and its giving me incompatible type
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
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

Joined: Mar 05, 2005
Posts: 16
Are you sure that :

request.getParameter("txtidnum")

Return the long value ?

Try

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

Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
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

Joined: Aug 04, 2004
Posts: 724
request.getParameter() returns ALWAYS and ONLY String


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
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

Joined: May 08, 2005
Posts: 23
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?
-------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getParameter...not taking Long