Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
JSP
JSTL + custom tags
Jorge Blaz
Ranch Hand
Posts: 53
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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:
<mytag:city postalCodeKey="myCode" context="page" />
where you tell the tag how to look up the value in the scoped variables.
3) Punt back to scriptlet expressions:
<mytag:city postalCode="<%= pageContext.getAttribute("myCode") %>" />
4) Upgrade to
Tomcat
5 and JSP 2.0/JSTL 1.1.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Btw, your topic title would better have been "EL and custom tags".
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Jorge Blaz
Ranch Hand
Posts: 53
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Remove variable from session in javascript
Mock Exam Chapter 9 Page 487
JSP page showing an XML response
date dispaly problem
theoretical question about sessions..
More...