• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jsp:usebean | NoClassDefFoundError

 
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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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 VI Editor Redhat
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic