• Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaBeans and JSP  RSS feed

 
Donna Bachner
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you implement a java bean from a JSP? I keep getting an error about the class attributes not being called properly. I have the following:
<jsp:useBean id="sample" class="sampleDBAO">
<jsp:setproperty name="sample" property="sample">
them name of the class is sampleDBAO.java
 
Jesus Angeles
Ranch Hand
Posts: 2069
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the exact error message?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I notice your bean is not in a package - this can cause problems because of the way the JVM looks for classes. Put your bean in a package and declare it properly in the useBean tag.

The location of the class file must be compatible with the declared package so the JVM can find it.

To avoid strange error messages and hard to find bugs, ALL classes used in servlets and JSP should be in packages.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP FAQ covers this in detail.
 
Donna Bachner
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thing I found the answer you need to put the name of the package down. I had it in a package just didnot know what it did for me. Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!