on 04-05-2006 4:41 PM
I am trying to change a jsp page for ISA 4.0
I would like to divide the netValue by the Quantity on the order.jsp page. How do I divide the returned value from item.getNetValue with the value from item.getQuantity?
They code as it stands at the moment:
<% String Z_temp1 = item.getNetValue(); %>
<% String Z_temp2 = item.getQuantity(); %)
<% out.println(Z_temp1 / Z_temp2 ; %> will not work as they are strings.
The jsp will not work when I have Z_temp1 as an int, I think the method getNetValue only returns strings. Is there a method of casting the returned value?
Please help
Thnks
Naidoo
You can cast your strings into integer, float, double datatypes. Instead of casting, we can just use the Double class and pass in a string into the constructor to perform the cast.
Here is how you do it.
<%
//passing string into constuctor of Double Class
Double zTemp = new Double(item.getNetValue());
Double zTemp2 = new Double(item.getQuantity());
Double dividedResult = zTemp/ZTemp2;
%>
To output to the screen, you should be using the following jsp tag:
<%= dividedResult %>
You should be looking at the Java API as your first reference:
http://java.sun.com/j2se/1.4.2/docs/api/
Look for the "Double" class on the left hand side of the screen. Be sure to look at the Constructor Summary and methods that are available (if you need to convert double to integer ect).
Hope this helps...
Message was edited by: Brendon Lipchen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.