Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

problem with javabeans

  Asked By: Willie    Date: Dec 30    Category: Java    Views: 803

I am working with the CarBean.java found in the WROX JSP Web
Devleopment book but I am having some problems.
Instead of throwing the CarBean.class into com.wrox.cars.CarBean
like they say to in the book, I put the file in
WEB-INF.classes.CarBean which was set up on the server when I signed
up for the web hosting service.

**** carPage2.jsp ****
<title>Using a JavaBean</title>
<h2>Using a JavaBean</h2>
<jsp:useBean id="myCar" scope="page" class="WEB-
INF.classes.CarBean" />
I have a <jsp:getProperty name="myCar" property="make" /> <br />
My car costs around $<jsp:getProperty name="myCar"
property="taxedPrice" />

*** CarBean.java ***
package WEB-INF.classes.CarBean;
import java.io.Serializable;

public class CarBean implements Serializable
private String make = "Ford";
public void setMake(String make)
this.make = make;
public String getMake()
return this.make;
public CarBean()
private double cost = 10000.00;
private double taxRate = 17.5;

public double getPrice(double p)
return (p + (p * (taxRate/100)));
public double getTaxedPrice()
return getPrice(cost);
private void setTaxedPrice(double newTaxRate)

When I compile CarBean.java, I get the following error:

C:\www.domainname.com\CarBean.java:2: ';' expected
package WEB-INF.classes.CarBean;
1 error
Process completed.

I am also seeing this error in the browser:

500 Servlet Exception
/carPage2.jsp:7: jsp:useBean can't find class `WEB-



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on problem with javabeans Or get search suggestion and latest updates.