Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
13.3 Setting Bean Properties
297
Listing 13.3 SaleEntry.java (continued)
}
return(roundToPennies(cost));
}
private double roundToPennies(double cost) {
return(Math.floor(cost*100)/100.0);
}
public double getTotalCost() {
return(getItemCost() * getNumItems());
}
}
Listing 13.4 SaleEntry1.jsp
Using jsp:setProperty
HREF="JSP Styles.css"
TYPE="text/css">
name="entry"
property="itemID"
value= <%= request.getParameter("itemID") %> />
<%
int numItemsOrdered = 1;
try {
numItemsOrdered =
Integer.parseInt(request.getParameter("numItems"));
} catch(NumberFormatException nfe) {}
%>
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved