For setting the Bean value in struts-config.xml we should use the form-beans tag.The form-beans tag might contain any number of bean property defined within form-bean as below.
Defining a Simple Bean Property
<form-beans>
<form-bean name="userBean" type="org.apache.struts.action.DynaActionForm">
<form-property name="userName" initial="This is Bean Value" type="java.lang.String" />
</form-bean>
</form-beans>
In the above code I am creating a userBean and setting its value is initialized to This is Bean Value.
Now in the action mapping part of the struts-config.xml I am going to map the above created bean to path as said below
<action-mappings>
<action path="/showBeanValue" type="org.apache.struts.actions.ForwardAction" parameter="/showBeanValue.jsp"/>
<action name="userBean" path="/Login" />
</action-mappings>
In the first line I am defining action path as showBeanValue and it is going to forward to page showBeanValue.jsp when some one access the showBeanValue.do in url.
In the second statement I am creating a dummy form since the the html form action should not be empty.
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<html:form action="/Login">
<bean:write name="userBean" property="userName"></bean:write>
<bean:write name="userBean" property="userAge"></bean:write>
</html:form>