• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

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.
0
simi
Asked:
simi
1 Solution
 
pellepCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now