File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes UseBean error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "UseBean error" Watch "UseBean error" New topic

UseBean error

Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
<jsp:useBean id="person" class="Employee" type="Person" scope="session" >
<jsp:setProperty name="person" property="name" value="ABCD" />
The above usage is giving the following error.

An error occurred at line: 1 in the jsp file: /empInput.jsp
Generated servlet error:
Person cannot be resolved to a type
public interface Person {

public abstract String getName();

public class Employee implements Person {
private String name;
public String getName() {
return name;
public void setName(String name) { = name;

Why the error message.
nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
Hi Sunder,

I tried out the example you posted. The code is proper and I did get the same error but when I put these classes inside packages it ran without any error.

So try putting the Person and Employee inside packages and check.

You will have to use the following in your jsp

<jsp:useBean id="person" class="com.test.Employee" type="com.test.Person" scope="session" >
<jsp:setProperty name="person" property="name" value="ABCD" />

<jsp:getProperty name="person" property="name"/>

where "com.test" is the package I had used.
[ May 20, 2007: Message edited by: nitin pai ]

Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
If you DO NOT put the bean file inside a package. It would not work.

Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
Thanks. I realised it after posting it.
I agree. Here's the link:
subject: UseBean error
It's not a secret anymore!