Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Output quote mark in JSTL?  RSS feed

 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I output using Jstl's out method text that has a ' in it?

e.g

<cut value="${current.name}"/>

where "current.name" = "Plan Explorer Bluetooth h'set" - what I get output is "Bluetooth h&amp;amp;amp;amp;amp;amp;#039;set"

I tried the escapeXml option set to true & false but no difference!

What am I doing wrong?

thanks

harry
 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in fact just noticed a slight difference -

if <cut value="${current.name}" escapeXml="true"/>

Plan Explorer Bluetooth h&amp;amp;amp;amp;amp;amp;#039;set

if <cut value="${current.name}" escapeXml="false"/>

Plan Explorer Bluetooth h&amp;amp;amp;amp;amp;#039;set

one less &

still totally stumped though!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure the current.name is correct before the cut ?
It may already contain extra characters in it. Try to output the value using a scriptlet, or EL
 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<cut value="${current.name}"/> definitely only contains "Explorer Bluetooth h'set"

What I'm trying to do is this -

Declare a variable - <c:set var="strLinesText"/>

Then I want to loop through a collection of objects appending each one's "name" to this var -

<c:forEach items="${package.items}" var="current" varStatus="status">
<c:set var="strLinesText">
<cut value="${strLinesText}"/>
<cut value="${current.name}"/>
</c:set>
</c:forEach>

but when I do a <cut value="${strLinesText}"/> after this loop the ' has been replaced with loads of & as shown before

Tried <cut value="${strLinesText}" escapeXml="true"/> and <cut value="${strLinesText}" escapeXml="false"/> but apart from one less & it's still wrong!

any ideas?
 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone please help with this? - this is doing my head in!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no other explanation than that the string is wrong when sent to the page.

Basic debugging: how can you prove your assertion that it is not?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!