JSTL <c:set> tag with <fmt> tag

Hi. I don't know much about JSTL, but someone with some knowledge was trying to help me out. Basically I'm trying to set a variable in JSTL with value equal to something referenced by a <fmt> tag. Then I try to get the value of this variable in a scriptlet through the pageContext. The code below doesn't work, however. All I'm getting is an empty string in the scriptlet. Any help would be appreciated.

      <c:set var="selectedValuePresented" value="<fmt:message key='<%= ResourceKeys.DF_SELECT %>'/>" />

      String selectedValuePresented = String.valueOf (pageContext.getAttribute("selectedValuePresented"));
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can't nest custom tags as attributes to other custom tags.
However, the c:set takes its value either from the "value" attribute, or the nested content.
You can probably do it like this:
 <c:set var="selectedValuePresented"><fmt:message key='<%= ResourceKeys.DF_SELECT %>'/></c:set>
I am presuming you have a JSP2.0 container (eg Tomcat 5), or are using the "runtime" version of JSTL.

I would question your need for scriptlet code though.  The whole point of JSTL is to minimize it in pages.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

I think that <fmt> can also be used to set variable. Please do like
<fmt:message key='<%= ResourceKeys.DF_SELECT %>' var="selectedValuePresented" />

Please try that out

willi_gamboaAuthor Commented:
Thank you. Both approaches work. Regarding minimizing scriptlet code, I completely agree. However, I'm a front end developer whose focus is on DHTML. So any quick way to get the Java developers' code to work with my front end stuff will work for me.

Glad I could help

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.