• 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

JSTL + custom tags

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

I want to pass a dynamic property to a custom tag. I'm using JSTL 1.0 + Jsp 1.2

I've tried this, but none of the above seem to work:

<mytag:city postalCode="<c ut value='${myCode}' />" />
<mytag:city postalCode="${myCode}" />

Any ideas of how to do this?. (the "myCode" variable is stored in page context)

Thanks in advance.
Jorge
 
Sheriff
Posts: 67746
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
In JSP 2.0 your second example will work just fine since the EL is evaluated by the JSP container.

Under JSP 1.2 you're kinda stuck because the EL is only interpreted by the JSTL tags.

Here are some options:

1) Evaluate the EL expression within your tag using the JSTL API. I've not done this (since I use JSP 2.0) so I don't know how hairy it is.

2) Do something like:


where you tell the tag how to look up the value in the scoped variables.

3) Punt back to scriptlet expressions:



4) Upgrade to Tomcat 5 and JSP 2.0/JSTL 1.1.
 
Bear Bibeault
Sheriff
Posts: 67746
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
Btw, your topic title would better have been "EL and custom tags".
 
Jorge Blaz
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best option would be number 1, but it will be hard to find examples
of how to do this.

Options 3 and 4 are good but I must use JSP 1.2 and I try to avoid scriptlets by using JSTL and custom tags.

So, i will try to do it with option 2.

Thanks for the help Bear, and you're right, the title should have been better EL and custom tags.
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic