*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "UseBean error" Watch "UseBean error" New topic
Author

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" />
</jsp:useBean>
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
---------------------------------
Person.java:
public interface Person {

public abstract String getName();

}
----------------------------------
Employee.java:
public class Employee implements Person {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.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:useBean>

<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: http://aspose.com/file-tools
 
subject: UseBean error