Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
296
Chapter 13 Using JavaBeans with JSP
Listing 13.3 SaleEntry.java 
package coreservlets;
/** Simple bean to illustrate the various forms
 *  of jsp:setProperty.
 */
public class SaleEntry {
  private String itemID = "unknown";
  private double discountCode = 1.0;
  private int numItems = 0;
  public String getItemID() {
    return(itemID);
  }
  public void setItemID(String itemID) {
    if (itemID != null) {
      this.itemID = itemID;
    } else {
      this.itemID = "unknown";
    }
  }
  public double getDiscountCode() {
    return(discountCode);
  }
  public void setDiscountCode(double discountCode) {
    this.discountCode = discountCode;
  }
  public int getNumItems() {
    return(numItems);
  }
  public void setNumItems(int numItems) {
    this.numItems = numItems;
  }
  
  // Replace this with real database lookup.
  
  public double getItemCost() {
    double cost;
    if (itemID.equals("a1234")) {
      cost = 12.99*getDiscountCode();
    } else {
      cost =  9999;
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




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

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