View Single Post
  #1 (permalink)  
Old October 2nd, 2003, 08:51 PM
wvmikep wvmikep is offline
Registered User
 
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with code in wrox book....

...on page 85 in Beginning JSP Web Development:

I have the following bean:

/*
 * CarBean.java
 *
 * Created on October 2, 2003, 8:36 PM
 */

package com.wrox.cars;
//package Templates.Beans;

import java.io.Serializable;
//import java.beans.*;

/**
 *
 * @author mike
 */
public class CarBean implements Serializable {

    public CarBean() {
    }

    private String make = "Ford";

    public String getMake() {
        return make;
    }

    public void setMake(String make) {
        this.make = make;
    }

    private double cost = 10000.00;
    private double taxRate = 17.5;

    public double getPrice() {
        double price = (cost + (cost * (taxRate/100)));
        return price;
    }

    private void setPrice(double newPrice) {
    }
}

...and the following JSP page:

<%@page contentType="text/html"%>
<html>
<head><title>Using a JavaBean</title></head>
<body>

<h2>Using a JavaBean</h2>

<jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />

I have a <jsp:getProperty name="myCar" property="make" /> <br />

My car costs $<jsp:getProperty name="myCar" property="price" />

</body>
</html>

The problem is, I get:
500 Unhandled exception thrown from /begjsp-ch04/carPage2.jsp:12
Unhandled exception thrown from /begjsp-ch04/carPage2.jsp:12

If I delete the whole line in the JSP page that starts with "My car costs..." the error goes away. This code is straight from the book. Any ideas?

Now, I realized I could just skip it and continue on in the book, which I would likely do, since until page 500, where it starts talking about struts, it doesn't look like I'll be doing much with beans anymore. However, if there is a solution, I'd like to have the piece of mind of knowing that I'm not crazy...if you know what I mean.

Reply With Quote