java - javax.el.PropertyNotFoundException IN SHOPPING CART -
i working on shopping cart when try display contents of cart gives me error called http status 500 - javax.el.propertynotfoundexception: property 'idnumber' not found on type cart.cartitembean – using bean on jsp diplay contents of cart.
shoppingcart.jsp
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <html> <head> <title>shopping cart</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> <p><font face="verdana, arial, helvetica, sans-serif"><strong>shopping cart</strong></font></p> <p><a href="modellist.jsp" mce_href="modellist.jsp">model list</a> </p> <table width="75%" border="1"> <tr bgcolor="#cccccc"> <td><strong><font size="2" face="verdana, arial, helvetica, sans-serif">model description</font></strong></td> <td><strong><font size="2" face="verdana, arial, helvetica, sans-serif">quantity</font></strong></td> <td><strong><font size="2" face="verdana, arial, helvetica, sans-serif">unit price</font></strong></td> <td><strong><font size="2" face="verdana, arial, helvetica, sans-serif">total</font></strong></td> </tr> <jsp:usebean id="cart" scope="session" class="cart.cartbean"/> <c:if test="${cart.lineitemcount==0}"> <tr> <td colspan="4"><font size="2" face="verdana, arial, helvetica, sans-serif">- cart empty -<br/> </tr> </c:if> <c:foreach var="cartitem" items="${cart.cartitems}" varstatus="counter"> <form name="item" method="post" action="cartcontroller"> <tr> <td><font size="2" face="verdana, arial, helvetica, sans-serif"><b><c:out value="${cartitem.partnumber}"/></b><br/> <c:out value="${cartitem.modeldescription}"/></font></td> <td><font size="2" face="verdana, arial, helvetica, sans-serif"><input type='hidden' name='itemindex' value='<c:out value="${counter.count}"/>'><input type='text' name="quantity" value='<c:out value="${cartitem.quantity}"/>' size='2'> <input type="submit" name="action" value="update"> <input type="submit" name="action" value="delete"></font></td> <td><font size="2" face="verdana, arial, helvetica, sans-serif">$<c:out value="${cartitem.unitcost}"/></font></td> <td><font size="2" face="verdana, arial, helvetica, sans-serif">$<c:out value="${cartitem.totalcost}"/></font></td> </tr> </form> </c:foreach> <tr> <td colspan="2"> </td> <td> </td> <td><font size="2" face="verdana, arial, helvetica, sans-serif">subtotal: $<c:out value="${cart.ordertotal}"/></font></td> </tr> </table> </body> </html>
cart.cartbean
package cart; import cart.cartitembean; import java.util.arraylist; public class cartbean { private arraylist alcartitems = new arraylist(); private double dblordertotal; int lineitemcount = alcartitems.size(); public int getlineitemcount() { return lineitemcount; } public void deletecartitem(string stritemindex) { int iitemindex = 0; try { iitemindex = integer.parseint(stritemindex); alcartitems.remove(iitemindex - 1); calculateordertotal(); } catch (numberformatexception nfe) { system.out.println("error while deleting cart item: " + nfe.getmessage()); nfe.printstacktrace(); } } public void updatecartitem(string stritemindex, string strquantity) { double dbltotalcost = 0.0; double dblunitcost = 0.0; int iquantity = 0; int iitemindex = 0; cartitembean cartitem = null; try { iitemindex = integer.parseint(stritemindex); iquantity = integer.parseint(strquantity); if (iquantity > 0) { cartitem = (cartitembean) alcartitems.get(iitemindex - 1); dblunitcost = cartitem.getunitcost(); dbltotalcost = dblunitcost * iquantity; cartitem.setquantity(iquantity); cartitem.settotalcost(dbltotalcost); calculateordertotal(); } } catch (numberformatexception nfe) { system.out.println("error while updating cart: " + nfe.getmessage()); nfe.printstacktrace(); } } public void addcartitem(int strmodelno, string strdescription, string strunitcost, string strquantity) { double dbltotalcost = 0.0; double dblunitcost = 0.0; int iquantity = 0; cartitembean cartitem = new cartitembean(); try { dblunitcost = double.parsedouble(strunitcost); iquantity = integer.parseint(strquantity); if (iquantity > 0) { dbltotalcost = dblunitcost * iquantity; cartitem.setidnumber(strmodelno); cartitem.settitle(strdescription); cartitem.setunitcost(dblunitcost); cartitem.setquantity(iquantity); cartitem.settotalcost(dbltotalcost); alcartitems.add(cartitem); calculateordertotal(); } } catch (numberformatexception nfe) { system.out.println("error while parsing string primitive types: " + nfe.getmessage()); nfe.printstacktrace(); } } public void addcartitem(cartitembean cartitem) { alcartitems.add(cartitem); } public cartitembean getcartitem(int iitemindex) { cartitembean cartitem = null; if (alcartitems.size() > iitemindex) { cartitem = (cartitembean) alcartitems.get(iitemindex); } return cartitem; } public arraylist getcartitems() { return alcartitems; } public void setcartitems(arraylist alcartitems) { this.alcartitems = alcartitems; } public double getordertotal() { return dblordertotal; } public void setordertotal(double dblordertotal) { this.dblordertotal = dblordertotal; } protected void calculateordertotal() { double dbltotal = 0; (int counter = 0; counter < alcartitems.size(); counter++) { cartitembean cartitem = (cartitembean) alcartitems.get(counter); dbltotal += cartitem.gettotalcost(); } setordertotal(dbltotal); }
}
cart.cartitembean
package cart; public class cartitembean { public int idnumber; private string title; private string image; private double dblunitcost; private int iquantity; private double dbltotalcost; public int getidnumber() { return idnumber; } public void setidnumber(int idnumber) { this.idnumber = idnumber; } public string getimage() { return image; } public void setimage(string image) { this.image = image; } public string gettitle() { return title; } public void settitle(string title) { this.title = title; } public double getunitcost() { return dblunitcost; } public void setunitcost(double dblunitcost) { this.dblunitcost = dblunitcost; } public int getquantity() { return iquantity; } public void setquantity(int quantity) { iquantity = quantity; } public double gettotalcost() { return dbltotalcost; } public void settotalcost(double dbltotalcost) { this.dbltotalcost = dbltotalcost; }
}
any highly appreciated
Comments
Post a Comment