File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jsp:usebean | NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:usebean | NoClassDefFoundError" Watch "jsp:usebean | NoClassDefFoundError" New topic
Author

jsp:usebean | NoClassDefFoundError

Lakshman Kumar
Greenhorn

Joined: Jan 05, 2007
Posts: 8
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

Joined: Dec 11, 2004
Posts: 13410

Can you post the code to your person class and your JSP?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Lakshman Kumar
Greenhorn

Joined: Jan 05, 2007
Posts: 8
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

Joined: Dec 11, 2004
Posts: 13410

This looks OK. Where did you put the Person.class file?
Lakshman Kumar
Greenhorn

Joined: Jan 05, 2007
Posts: 8
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.
 
subject: jsp:usebean | NoClassDefFoundError
 
Similar Threads
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError
NoClassDefFoundError