I wanted to write price for the product in vector using number format. Here is my code
<%!
class product
{
public String name;
public int price;
public String image;
public product()
{
}
}
%>
<%
NumberFormat nf = NumberFormat.getCurrencyInstance();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setCurrencySymbol("$ ");
dfs.setGroupingSeparator('.');
dfs.setMonetaryDecimalSeparator('.');
((DecimalFormat) nf).setDecimalFormatSymbols(dfs);
Vector<product> vec = new Vector<product>();
gallery obj;
obj=new product();
obj.nama="Dark Chocolate";
obj.price=Integer.parseInt(nf.format(3040000));
obj.image="Image/Dark chocolate.jpg";
vec.add(obj);
obj = new product();
obj.nama="Woodhouse Chocolates";
obj.price=Integer.parseInt(nf.format(6000500));
obj.image="Image/woodhouse_chocolates.jpg";
vec.add(obj);
obj = new product();
obj.name="Semisweet Chocolate";
obj.price=Integer.parseInt(nf.format(3050000));
obj.image="Image/Semisweet chocolate.jpg";
vec.add(obj);
obj = new product();
obj.name="White Chocolate";
obj.price=Integer.parseInt(nf.format(2948000));
obj.image="Image/White chocolate.jpg";
vec.add(obj);
%>
It said
org.apache.jasper.JasperException: An exception occurred processing JSP page
at this section
obj.price=Integer.parseInt(nf.format(3040000));
obj.price=Integer.parseInt(nf.format(6000500));
obj.price=Integer.parseInt(nf.format(3050000));
obj.price=Integer.parseInt(nf.format(2948000));
Where's my the mistake? Could anyone help me?