Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:usebean | NoClassDefFoundError

 
Lakshman Kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

i have question.
I added a 'person' object to the request attribute in a servlet and forwarded the request to a jsp. In jsp when i used request.getAttribute("person") its woking fine.

But the problem is with <jsp:useBean>, when this is used i'm getting NoClassDefFoundError: Person (Wrong name foo/Person). (But if the same code is replaced with request.getAttribute(..) its working fine).

I imported foo.Person in the Jsp file.

Please help me to solve this...thanks in advance

Lakshman
[ July 17, 2007: Message edited by: Lakshman Kumar ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code to your person class and your JSP?
 
Lakshman Kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set the instance of the Person class to the request attribute in a servlet and forwarded to the below jsp (result.jsp)

Here is my jsp code:
result.jsp
**********
<%@ page import="foo.Person">
<html>
<body>
<jsp:useBean id="person" class="foo.Person" scope="request" />
Name : <jsp:getProperty name="person" property="name" />
</body>
</html>

Person.java
***********
package foo;
public class Person
{
private name;
public setName(String n)
{
this.name=n;
}
public getName()
{
return name;
}
}

Please reply.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks OK. Where did you put the Person.class file?
 
Lakshman Kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

Now it is working.
The mistake i have done is in the jsp:useBean i did not give the package structure of the Person class.

Any how...Thanks a lot.

Lakshman.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic