• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Passing a bean property to a custom tag using JSTL

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI all,
Within a jsp page I am currently using a bean, a custom tag and jstl.

My bean is being accessed by jstl and a String property of the bean is being passed to my custom tag. However, the value that is actually being passed to the custom tag is
<c ut value=�${bean.name}� /> and not the value of bean.name.

I thought by the time the custom tag was executed the <c ut value=�${bean.name}� /> would have printed out the value of bean.name.

Can someone please let me know how to get the value of bean.name to the custom tag as a property.

Thank you

david
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
set the bean in the pageContext to have it available to the JSP.
The pageContext effectively means the session or request (or make it global, yugh).
 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.
Is there any chance you can give me an example.

Thank you david
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by david allen:

. . . the value that is actually being passed to the custom tag is
<c ut value=�${bean.name}� /> and not the value of bean.name.



I see you're using ${bean.name} in the JSTL <cout> tag value parameter. Are you using the same thing in your custom tag? For example:

<myLib:myTag myParam="${bean.name}" />
 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gagnon,

that is exactly what I am using. The example you provided is the same syntax that I have.

What am I doing wrong?

Thank you
David
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic