Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UseBean error

 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you DO NOT put the bean file inside a package. It would not work.
 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I realised it after posting it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic