How to use the <bean: write> tag in strut 1.2?
Javadoc for <bean:write> :
Specifies the name of the bean attribute that is being accessed to get the value specified by the property (if specified). If the property is not specified, the value of this bean will be displayed.
Essentially, if you have a JavaBean (with getters and setters),
Person person = new Person; request.setAttribute("person", person); by setting <bean:write name="person" property="age" /> , you tell Struts to first find the person object first from the PageContext . If not found, then request , then session , then application area.
The property="age" attribute (from the <bean:write /> ) is called by the getter getAge() method from the person object (regardless of whether an instance variable called age on bean exists).
Hope this helps.
The "name" attribute must indicate the name of the bean. For example, if you are trying to derive a property from an ActionForm, the name attribute must be set to the name of the ActionForm, and the property attribute must be set to the ActionForm property that you want to write. Therefore, in this case, you can:
<bean:write name="productInfo" property="summary" /> If you declare a non-ActionForm bean using a tag, for example, the name attribute will be set to the name of the specified bean:
<bean:define id="displayText" value="Text to Display" /> <bean:write name="displayText" /> Note that the property attribute is missing in this case, and in this case the tostring value of the bean itself will be displayed.