• 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

Bean setter methods........

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1. If there is no setter method is defined for a bean property will it be an error. In the jsp if we try to set the property value using <jsp:setProperty> what will happen??

2. If the setter method is present and we are not setting the value by using <jsp:setProperty> or by other means, will the default values(for stings empty sting and for integers 0 like ........) are set for these properties?

Thanks in Advance,
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-----------------------------------------------------------------------
If there is no setter method is defined for a bean property will it be an error. In the jsp if we try to set the property value using <jsp:setProperty> what will happen??
----------------------------------------------------------------------

For <jsp:setProperty> standard action,
Internally JSP implementation object puts code to call setter method on the specified bean and when it doesnt find the setter method definition,
it shouts a compile error

Murali
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To answer question 2, the default value will be however you defined the bean class.
For instance: (inside a class)
private String myValue1; // default is null
private String myValue2 = null; // default is also null
private String myValue3 = ""; // default is empty string
private String myValue4 = "study hard"; // default is study hard

// TODO create setter methods later
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Passing SCJP first should answer question 2 too
reply
    Bookmark Topic Watch Topic
  • New Topic