Setting Bean Properties in JSP
Second try on this question.
I have a JSP with the following tags:
<jsp:useBean class="org.trollope.DbAccess" id="dba2">
<jsp:setProperty name="dba2" param="user" property="jdbcUser"> </jsp:setProperty>
</jsp:useBean>
It doesn't work -- I just getnull
when I retrieve the property:
Bean property is: <jsp:getProperty name="dba2" property="jdbcUser"></jsp:getProperty>
However, if I insert this scriptlet immediately after the "useBean" tag, the property is set and I can retrieve it using the above getProperty tag:
<%
String str = (String) request.getAttribute("user");
dba2.setJdbcUser(str);
%>
So, without scriptlet, output is:
Bean property is:null
With scriptlet, output is:
Bean property is: powem
I really want to know what I am doing wrong and would appreciate any tips. One thing it has occurred to me to note is that this page is actually being called through RequestDispatcher.forward() in a servlet. I don't know if that matters or not.
Thanks.
mp

