File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Bean setter methods........ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Bean setter methods........" Watch "Bean setter methods........" New topic
Author

Bean setter methods........

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
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,


Narasimha
Murali Mohan A
Greenhorn

Joined: Nov 25, 2005
Posts: 4
-----------------------------------------------------------------------
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
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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


A good workman is known by his tools.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Passing SCJP first should answer question 2 too


[My Blog]
All roads lead to JavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Bean setter methods........