• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to assign ${somevalue} to a bean using jsp:setproperty

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm trying to set a value to the bean.
The value is from DB

<sql:query var="items">
SELECT name FROM emp
</sql:query>

<c:forEach var="row" items="${items.rows}">
<jsp:useBean id="empName" class="test.emp">
<jsp:setProperty name="empName" property="empName" value="${row.name}"/> </jsp:useBean>

The value that is setting is
${row.name}
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a bean named empName and a property named empName. Bad idea. Very confusing and likely to lead to name collisions.

Either use the JSTL or don't. There's no need to use <jsp:setProperty> if <c:set> is available.
 
Ravi Kumar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,
I used the following code
<jsp:useBean id="chkBxNm" scope="session" class="TUnit.TUnitNmBean" />
<c:set target="${chkBxNm}" property="TSName" value="${row.TSName}" />
 
reply
    Bookmark Topic Watch Topic
  • New Topic