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

hi

I am preparing for scwcd exam. And i'm referring the Head First Servlets & JSP.

in the jsp section there is a example for <jsp:useBean>.

In this example i'm using one servlet program and one Bean program and one jsp.

Both servlet and bean code i saved in the classes folder and jsp in the root.

Problem is if i use package for the bean class and fully qualified class name in <jsp:useBean> it is working fine and gives the output . But if the package is removed means it is giving the error like org.apache.jasper.JasperException: Unable to compile class for JSP

and saying the

An error occurred at line: 5 in the jsp file: /result.jsp

Generated servlet error:

Person cannot be resolved or is not a type

Where the Person is a Bean code...

here is my full source code...

Person.java

--

public class Person {

private String firstName;

public void setFirstName(String firstName) {

this.firstName = firstName;

}

public String getFirstName() {

return firstName;

}

public Person()

{}

}

ServletTest.java

--

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

public class ServletTest extends HttpServlet{

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {

Person p = new Person();

p.setFirstName("Kathy");

request.setAttribute("person", p);

RequestDispatcher view = request.getRequestDispatcher("result.jsp");

view.forward(request, response);

}

}

result.jsp

<HTML>

<BODY>

<jsp:useBean id="person" class="Person" scope="request" />

Person created by servlet : <jsp:getProperty name="person" property="firstName"/>

</BODY>

<HTML>

I am using Tomcat 5.5 and jdk 1.4

Kindly somebody help me out to solve this problem

thanks in advance

chithrakumar

[2075 byte] By [chithrakumara] at [2007-11-27 2:31:44]
# 1
You must use the fully-qualified class name. You can't omit the package name.
RichFearna at 2007-7-12 2:46:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...