aspose file tools
The moose likes JSP and the fly likes trouble with first time bean. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "trouble with first time bean. "no such property" exception" Watch "trouble with first time bean. "no such property" exception" New topic
Author

trouble with first time bean. "no such property" exception

Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
I'm new to using beans in jsp's, and I've written a java class that is basically nothing but private variables, with public getter and setter methods to access them. However, when I try to set the values, i get a "no such property" exception. Of course I've checked to make 100% certain the parameter names and the property names in the java class are identical, the class file is in the right place/package in the webinf/classes directory, etc. I'm using JRun4. Is there something I'm missing here? Can I not simply place the class file in the proper package in webinf/classes, point <jsp:useBean> to the right place to create the object, and be ready to go or do I have to jar the class file? As long as the property name and the parameter name are identical, i should be able to set the properties using <jsp:setProperty id="beanName" property="*">, right? Like I said, I'm new to this, so please forgive for the lame question. Any hints will be greatly appreciated.
[ September 02, 2004: Message edited by: Bill Brasskey ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56541
    
  14

Yes, that should work. What names are you giving to the form elements, and what are their corresponding mutators in your bean?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
Form element name is (for example)"applicant_last_name", with the corresponding variable in the java class being identical.
[ September 02, 2004: Message edited by: Bill Brasskey ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56541
    
  14

Form element name is (for example)"applicant_last_name", with the corresponding variable in the java class being identical.


What you name the variable doesn't mean a hill of beans (pun absolutely intended). You need to familiarize yourself with the JavaBean property rules a bit.

If the name of your form element is "applicantLastName", your bean needs to have a mutator (setter) with the name setApplicantLastName. Note the casing; it's mandatory.

If you don't follow the JavaBean property naming rules, it just won't work.
Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
ahhhhh...
indeed.
thanks, man.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: trouble with first time bean. "no such property" exception
 
Similar Threads
Unable to Call Action Servlet when datasource elememt in kept struts-config.xml
Can't get my simple bean to work!
Data not persisting, when it is sent through service layer
hi
Unable to find setter method for attribute: locale