Solved

set property for a bean with a value from the request

Posted on 2002-04-21
8
178 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
 
LVL 33

Expert Comment

by:knightEknight
ID: 6959917
good catch CJ, that was a cut-n-paste error on my part.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
decryption not working 5 80
constructor overloading 2 73
Set up Wildfly 10 8 318
Java Script nested call 3 53
A Short Story about the Best File Recovery Software ā€“ Acronis True Image 2017
We have come a long way with backup and data protection ā€” from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final pā€¦
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now