1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Rep Power

    Question jsp package directory structure problem

    I'm new and trying to follow an example from a wrox book on how to set up a jsp with a bean. I'm doing something wrong but I can't figure out what my problem is....

    Here's the story...

    I compile my .java file from the following directory

    D:\Tomcat 4.1\webapps\begjsp-ch04\web-inf\classes

    as follows

    javac com\wrox\cars\CarBean.java

    I point my browser to


    and I get this error:

    type Exception report


    description The server encountered an internal error () that prevented it from
    fulfilling this request.


    org.apache.jasper.JasperException: Unable to compile class for JSP

    An error occurred at line: 14 in the jsp file: /begjsp-ch04/carPage.jsp

    Generated servlet error:
    [javac] Compiling 1 source file

    D:\Tomcat 4.1\work\Standalone\localhost\_\begjsp-ch04\carPage_jsp.java:49:
    package com.wrox.cars does not exist

    com.wrox.cars.CarBean myCar = new com.wrox.cars.CarBean();
    out.write("\r\n\t\r\n\tI own a ");

    here's the contents of carPage.jsp


    <title>Using a JavaBean</title>



    <h2> Using a JavaBean</h2>

    <% com.wrox.cars.CarBean myCar = new com.wrox.cars.CarBean(); %>

    I own a <%= myCar.getMake() %> <br />

    <% myCar.setMake("Ferrari"); %>

    Now I own a <%= myCar.getMake() %>



    here's the contents of CarBean.class

    package com.wrox.cars;

    import java.io.Serializable;

    public class CarBean implements Serializable {

    public CarBean(){


    private String make = "Ford";

    public String getMake() {
    return make;


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



    <***Location of my class CALLED CarBean.class********>

    10/07/2002 03:03 PM 458 CarBean.class
    10/03/2002 01:53 PM 279 CarBean.java

    D:\Tomcat 4.1\webapps\begjsp-ch04\web-inf\classes\com\wrox\cars>

    <***Location of my JSP CALLED carPage.jsp ********>

    10/07/2002 03:25 PM 319 carPage.jsp

    D:\Tomcat 4.1\webapps\ROOT\begjsp-ch04>

    <***environmental variables**********>

    CATALINA_HOME = D:\Tomcat 4.1

    CLASSPATH = D:\Tomcat 4.1\common\lib\servlet.jar;.;
    D:\Tomcat 4.1\webapps\begjsp-ch04\web-inf\classes;

    JAVA_HOME = D:\j2sdk1.4.0_01

    PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
    C:\Program Files\Common Files\Adaptec Shared\System;D:\j2sdk1.4.0_01\bin
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Sacramento, CA
    Rep Power
    You say your jsp is in "D:\Tomcat 4.1\webapps\ROOT\begjsp-ch04" and your bean is in "D:\Tomcat 4.1\webapps\begjsp-ch04"?

    Those need to be the same.

IMN logo majestic logo threadwatch logo seochat tools logo