• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java bean error message

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic