Solved

set property for a bean with a value from the request

Posted on 2002-04-21
8
181 Views
Last Modified: 2010-04-01
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
Comment
Question by:simi
8 Comments
 
LVL 4

Accepted Solution

by:
pellep earned 25 total points
ID: 6959435
try

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

Expert Comment

by:knightEknight
ID: 6959765
or:

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

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

Expert Comment

by:cheekycj
ID: 6959854
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 33

Expert Comment

by:knightEknight
ID: 6959917
good catch CJ, that was a cut-n-paste error on my part.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6960603
isn't that exactly what you had??
<curiously>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6960615
no, the original had <%= and pellep suggested <%
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6960743
Ah I see.

Surprised that worked.. learn somethin new everyday..

CJ
0
 

Expert Comment

by:jayametts
ID: 10258858

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Stuck in Bootstrap WysiHtml Editor 3 39
spring dependency injection using java config 2 85
Java Exception example issues 11 84
withoutString  challenge 40 198
If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
Adding Computers to AD groups through an SCCM Task Sequence
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question