• Post Reply Bookmark Topic Watch Topic
  • New Topic

EL: concatenating a literal '$'

 
Dan Murphy
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an attribute in my JSP named 'item' that has a 'price' property. I need to prefix this price with a '$' sign so that it displays something like '$20.99'. Ideally, I'd like to do this without using scriptlets.

A further complication, is that I need to do this within a <ctherwise> tag. I've tried the following:



But it doesn't seem to work, any suggestions?

Thanks in advance,
Dan
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<ctherwise>$<cut value="${item.price}"/></ctherwise>


Just put it in template text. Why complicate things?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an additional simplification, if you don't need any HTML-escaping, you can eliminate the <cut>:

(assumes JSP 2.x)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!