|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hi there.
I have a form where customers input numbers(both types like 123 and 123.54), and i need to pass this numbers to .jsp file and do some arithmetic operations with it. So i have form. here is piece of form's code: ----------------------------------------------- <form name="form1" method="get" action="update.jsp"> <input type="text" name="price" size="30"> <input type="submit" name="submit" value="Submit"> </form ----------------------------------------------- Next here is the piece of jsp file code: --------------------------------------------------------------- <% //getting the parameter String fprice = request.getParameter("price"); //converting parameter to double type Double x = Double.valueOf(fprice) // now i want to do some arithmetic double y = x / 1.18; %> -------------------------------------------------------------------- And i have error here: org.apache.jasper.JasperException: Unable to compile C:\tomcat\work\DEFAULT\ROOT\ladu\update_12.java:96: Incompatible type for /. Can't convert java.lang.Double to double. double y = x / 1.18; Could any1 help me plz? best regards... |
|
#2
|
|||
|
|||
|
1. <%
2. //getting the parameter 3. String fprice = request.getParameter("price"); 4. //converting parameter to double type 5. Double x = Double.valueOf(fprice) 6. // now i want to do some arithmetic 7. double y = x / 1.18; 8. %> Ok, the error seems to be in line #5 where you are using the Java object Double instead of the Java primitive double. I know you are trying to convert fprice into a double, and the best way to do that is: String fprice = "15"; Double x = Double.valueOf(fprice); double x1 = x.parseDouble(fprice); double y = x1 / 1.18; I hope this works. :-) Devin Hendricks sitesuwant@sitesuwant.com www.sitesuwant.com If you need a part-time telecommuting 16 year old Java developer, please contact me, I am looking for work for 10 hours a week. I also know HTML, JavaScript, CSS, DHTML, and PHP & MySQL; I've used them extensively. Thanks. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Plz help, problems with arithmetic... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|