aspose file tools*
The moose likes JSP and the fly likes jsp:setProperty tag not setting property in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:setProperty tag not setting property in bean" Watch "jsp:setProperty tag not setting property in bean" New topic
Author

jsp:setProperty tag not setting property in bean

Patrick Noah
Greenhorn

Joined: Aug 22, 2011
Posts: 28
I have the following dynamic form FillDetails.html:

SaveName.jsp:

UserData.java:

If you select abandoned car in the dropdown and fill in values for the make and color the make and color do not get set in the bean! They are null. Why is this? My folder structure is TOMCAT_FOLDER/webapps/email/UserData.java, FillDetails.html, SaveData.jsp. There is also a WEB-INF folder with /classes/user/UserData.class.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

I haven't used setProperty in that way since about 2001. Submitting a form to a JSP is no longer considered an acceptable practice.

Forms should be submitted to servlet controllers that process the data and delegate activities to the model as necessary. Then, the request is forwarded to a JSP to display the results of the operation.

Have you read this article yet?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
The issue is that you have named your fields using names starting with an upper-case letter.

Try changing the names of your input controls on the html page: Make-->make and Color-->color and then see if it works.
ie


By the Javabeans specification, properties/variables should start with a lower case letter, and class names should start with an upper case letter.
You need to follow this pattern in order for the java bean to be populated correctly with values coming from the JSP page.
Patrick Noah
Greenhorn

Joined: Aug 22, 2011
Posts: 28
thanks Stefan.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jsp:setProperty tag not setting property in bean
 
Similar Threads
problem with bean in tomcat
Problem in retrieving List from class and displaying it in JSP in struts2
Deploying JSP application
Where to put bean class in Tomcat?
How do I set a bean value from a dropdown?