Or you can also do something like :-
String variable = request.getParemeter("anotherVariable");
try {
float value= Float.parseFloat(variable);
} catch (NumberFormatException e) {
float = 0;
}
-----Original Message-----
From: SSM Technologies [SMTP:[EMAIL PROTECTED]]
Sent: Wednesday, December 27, 2000 12:32 PM
To: [EMAIL PROTECTED]
Subject: Re: Casting
Hi Hamid,
try this one,using a wrapper class
String variable = request.getParemeter("anotherVariable");
Float val= new Float(variable);//Its float wrapper
float value=val.floatValue();/*Its method of Float class converting the
Float object into primitive data type float */
Bye,
Viraj
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Hamid
Farooqui
Sent: Monday, December 25, 2000 1:53 PM
To: [EMAIL PROTECTED]
Subject: Casting
Hi all
I understand that what we get by
variable = request.getParemeter("anotherVariable")
is always a string
I need to use the variable in some calculations and need this as a float
But it seems casting doesnt work in servlet
Anybody has any idea as to how to convert this to a float
TIA
Hamid
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html