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("someOtherProperty")%>"/>

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("someOtherProperty")%>, I am getting printed the value of the someOtherPropery, which is OK.

Thanks.
simiAsked:
Who is Participating?
 
pellepConnect With a Mentor Commented:
try

<jsp:setProperty name="someBean" property="someProperty" value="<%session.getValue("someOtherProperty")%>"/>
0
 
knightEknightCommented:
or:

<%! String prop = session.getValue("someOtherProperty"); %>

<jsp:setProperty name="someBean" property="someProperty" value="<%= prop %>"/>
0
 
cheekycjCommented:
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("someOtherProperty"); %>

<jsp:setProperty name="someBean" property="someProperty" value="<%=prop%>"/>

CJ
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
knightEknightCommented:
good catch CJ, that was a cut-n-paste error on my part.
0
 
cheekycjCommented:
isn't that exactly what you had??
<curiously>
0
 
knightEknightCommented:
no, the original had <%= and pellep suggested <%
0
 
cheekycjCommented:
Ah I see.

Surprised that worked.. learn somethin new everyday..

CJ
0
 
jayamettsCommented:

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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.