I can't figure this one out:
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?
Thanks
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?
Thanks