• Post Reply Bookmark Topic Watch Topic
  • New Topic

In valid Bean

 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I compiled a javabean called DBBean and copied the class file in classes under WEB-INF. Then I have following code in JSP:

<jsp:useBean id="mydb" class="DbBean" />
<tr>
<td>Ear Tag </td><td> <%= mydb.xx() %></td>
</tr>

xx is a method in the bean. I get this error message:
org.apache.jasper.JasperException: /run_jsp0.jsp(388,0) The value for the useBean class attribute DbBean is invalid

What else I need to do. My bean is a class and is not in a package. So I guess I do not need to import etc. Seems it can not find Bean.

Any clues?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and is not in a package

That's your problem. Beans and servlets must be in packages for them to work properly. Besides, it's just good practice.
 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But, I have only once class in the application. Seems kind of overhead to create a folder/package. I sould be able to work with a stand alone class.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The good news is that, as you probably know, packages are easy to create. The bad news is that if you want it to work, you need to create one.

Also, why did you change your display name from a valid one to an invalid one?
 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Used to using first name at work. Anyway, to be with the policy of this web site the full name is back.

Anyway, back to the question I have not seen in the book I have on JSP stating that I need to use only packaged Java bean to call from JSP. In fact example given is based on class. I guess in my case it is a class path issue, seems it should work w/o creating a package.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!