Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java bean error message  RSS feed

 
Michael Crutcher
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the java bean:

Within a jsp file the bean is referenced:

This works:

This doesn't:

I get this message back:
Cannot find any information on property 'property2' in a bean of type 'NewBean'
What the heck is going on here? The recognition of properties seems completely arbitrary.
I've tried all of these things:
1. Changing case on both sides (jsp/bean)
2. Stopping and restarting tomcat
3. Recompiling the bean
4. Providing the property as an instance variable
5. Not providing the property as an instance variable
6. Providing both get and set methods
7. Providing only a get method
All of these seem to have absolutely no effect. Tomcat just randomly decides that it's going to find a property or not.
Any help would be greatly appreciated.
Thanks,
Michael Crutcher
 
Lon Allen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
property and property2 are supposed to be private instances variables in your bean. Typically:

You are referencing bean properties in your JSP that do not exist in the bean.
The following will work:

I have all my beans like this and have never had a problem accessing any of the properties in them.
Be sure and associate all properties with input variables via:
<jsp:setProperty name="listboxes" property="*" />
Don't forget that you can also access the properties in a bean via the public methods you created.
Example:
<%= listboxes.getProperty() %>
<% out.print(listboxes.getProperty2()); %>
hth,
Lon Allen
[ November 04, 2002: Message edited by: Lon Allen ]
[ November 04, 2002: Message edited by: Lon Allen ]
[ November 05, 2002: Message edited by: Lon Allen ]
[ November 05, 2002: Message edited by: Lon Allen ]
 
Michael Crutcher
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. Unfortunately as mentioned:
4. Providing the property as an instance variable
5. Not providing the property as an instance variable
6. Providing both get and set methods
7. Providing only a get method

I've tried what you've suggested. Your suggestion also doesn't help explain why two properties defined within the bean in exactly the same way are treated differently by the jsp engine. By this I mean the get property call on property one succeeds, then why in the heck does the get property call on property2 succeed? The syntax is exactly the same.
This is extrodinarily frustrating. Any help is greatly appreciated.
Is this a bug in tomcat?
Michael Crutcher
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pardon me if I'm missing something, but how do you expect the JSP servlet to have access to the accessor of Property2 if you have it declared private?
bear
 
Lon Allen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad! Oversite... meant to change it to public. Cut-n-paste will get you in trouble. I knew that there was something else I had wanted to mention to the original poster: "You need to change the getProperty2() method to public".
Thanks for catching that Bear.

Lon
[ November 05, 2002: Message edited by: Lon Allen ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!