I was trying to find different ways to set bean properties from request parameter values and then get bean properties to be displayed. The code block below should work but i saw an alternate way which i provided in the the last code block. The only thing i don't understand is the property attributes * value. With my code you can clearly see how the beans properties are set via the request params, then retrieved, whereas in the bottom example it seems like there is somthing going on under the sheets. With this line <c
ut value="${userInfo.userName}" how is the link between the html component and the bean property acheived? It seems the * enables the beans properties to be set and read at the same time but does it also allow the request parameter to be grabbed?
Code:
<jsp:useBean id="userInfo" class="com.ora.jsp.beans.userinfo.UserInfoBean"/>
<jsp:setProperty name="userInfo" property="userName"
value="${param.userName}"/>
<jsp:getProperty name="userInfo" property="userName"/>
Code:
<jsp:useBean id="userInfo"
class="com.ora.jsp.beans.userinfo.UserInfoBean">
<jsp:setProperty name="userInfo" property="*" />
</jsp:useBean>
<c:out value="${userInfo.userName}" /><br>