you get it in a temp string
Sring strTemp = request.getParameter("PurchaseAmount");
long theAmount = 0L;
if ( (strTemp != null) && !strTemp.equals(""))
theAmount = Long.parseLong(strTemp);
hope this help
-----Original Message-----
From: "Mike Curwen" <mikec@q...>
Date: Tue, 24 Jul 2001 10:01:25 -0500
To: "Pro_JavaServer_Pages" <pro_jsp@p...>
Subject: [pro_jsp] RE: String conversion HELLLPP!!
> long theAmount = Long.parseLong(request.getParameter("PurchaseAmount"));
>
> This can be somewhat dangerous, since if "PurchaseAmount" returns null, you
> will throw a NumberFormatException. So perhaps this:
>
> long theAmount = 0L;
> try {
> theAmount = Long.parseLong(request.getParameter("PurchaseAmount:));
> } catch (NumberFormatException nfe) {
> //what do you do if PurchaseAmount doesn't convert to long ?
> }
>
>
>
> -----Original Message-----
> From: Paul Brady [mailto:phbrady@b...]
> Sent: Monday, July 23, 2001 11:54 PM
> To: Pro_JavaServer_Pages
> Subject: [pro_jsp] String conversion HELLLPP!!
>
>
> This should be simple but apparently it's not. All I need to do is get a
> value from a parameter and put it into a "long", so I can do math on it, eg
>
>
> long theAmount = request.getParameter("PurchaseAmount");
> // throws exception "can't convert string to long"
>
>
> Parameter values being strings by default, what do I do??
>
> Thanks,
> PB
>
>
>