Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL fmt currency - Only displaying the currency symbol

 
Phil Jahan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Is there a way to only display the currency symbol (�, $ etc) using JSTL's fmt tag? I have access to a currency code and want to display the currency symbol for it next to my form input box but can't figure out how to do it.

Thanks
 
Joanne Thomas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Phil,

Did you ever get an answer to this? I am searching for the same thing.

Thanks,
Jo.
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be a bit of a misuse of the JSTL tag.
The currency symbol is available from the class java.util.Currency. You should obtain it from there.


If you have an instance of the Currency object already, you can just use ${currency.symbol}
If you need to obtain an instance of the currency first, use the Currency.getInstance(currencyCode) method.
This is not directly invokable from EL, but seeing as it is a static method you could define a custom EL function for it.
Personally I would just instantiate the Currency object, and set it as a request attribute so that EL can use it from there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!