Solved

set property for a bean with a value from the request

Posted on 2002-04-21
8
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

696 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