simi
asked on
set property for a bean with a value from the request
Hi,
Here is an example of what I want to achieve.
<jsp:setProperty name="someBean" property="someProperty" value="<%=session.getValue ("someOthe rProperty" )%>"/>
Basically I want to assign to a bean property another property comming from the session object.
With the syntax from above, I keep getting an error message "Attribute someOtherProperty has no value".
However, if I replace the code from abobe with
<%=session.getValue("someO therProper ty")%>, I am getting printed the value of the someOtherPropery, which is OK.
Thanks.
Here is an example of what I want to achieve.
<jsp:setProperty name="someBean" property="someProperty" value="<%=session.getValue
Basically I want to assign to a bean property another property comming from the session object.
With the syntax from above, I keep getting an error message "Attribute someOtherProperty has no value".
However, if I replace the code from abobe with
<%=session.getValue("someO
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the only change to knightEknight's code I would make is
make the prop a local var.. whenever I use JSP declaration scriptlet I always run into scoping issues.
<% String prop = session.getValue("someOthe rProperty" ); %>
<jsp:setProperty name="someBean" property="someProperty" value="<%=prop%>"/>
CJ
make the prop a local var.. whenever I use JSP declaration scriptlet I always run into scoping issues.
<% String prop = session.getValue("someOthe
<jsp:setProperty name="someBean" property="someProperty" value="<%=prop%>"/>
CJ
good catch CJ, that was a cut-n-paste error on my part.
isn't that exactly what you had??
<curiously>
<curiously>
no, the original had <%= and pellep suggested <%
Ah I see.
Surprised that worked.. learn somethin new everyday..
CJ
Surprised that worked.. learn somethin new everyday..
CJ
weird. you got to have = sign.
that's what I see for struts 1.1 .. i get a message asking for = sign inside the assignment tag.
<%! String prop = session.getValue("someOthe
<jsp:setProperty name="someBean" property="someProperty" value="<%= prop %>"/>