Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL: 2 questions: no string concenating? no escaping characters?

 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
first a 3x thank you for Shawn Bayern:
1. JSTL is very clear and easy to use
2. Your book is very clear and easy to use (I think even for pure dhtml-designers)
3. JSTL really speeds me up
I have 2 questions:
1. There is no String concenating in JSTL?
When I try something like:
<c ut value="${entry.cat_name + 'something completly different, but a String'}"/>
it seems to expect double values for doing adition of numbers.
2. Is it possible to escape " or '?
When I tried to dynamize some javaScript calls to build one of those fancy dhtml-navigators, it didn't work first, when I tried something similar to this:
<c ut value="${'addParent(\"a name\")'}"/>
I managed those problems by concenating the Strings I need for the javaScript in the Bean and using the very important escapeXml="false" parameter.
Just for curiosity, if anybody knows:
- am I missing something?
- migth String concenating and escaping of characters be introduced in further releases or is it banned as quick-hack which confuses the page designers?
regards Axel
[ November 08, 2002: Message edited by: Axel Janssen ]
[ November 08, 2002: Message edited by: Axel Janssen ]
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Axel Janssen:
Hi,
first a 3x thank you for Shawn Bayern:
1. JSTL is very clear and easy to use
2. Your book is very clear and easy to use (I think even for pure dhtml-designers)
3. JSTL really speeds me up


Hi Axel. Thanks for the note - I'm glad you're finding JSTL and JSTL in Action useful.

I have 2 questions:
1. There is no String concenating in JSTL?
When I try something like:
<cut value="${entry.cat_name + 'something completly different, but a String'}"/>
it seems to expect double values for doing adition of numbers.

Right - there's no reason for that kind of concatenation. Instead, simply use two back-to-back <cut> tags.

2. Is it possible to escape " or '?
When I tried to dynamize some javaScript calls to build one of those fancy dhtml-navigators, it didn't work first, when I tried something similar to this:
<cut value="${'addParent(\"a name\")'}"/>
I managed those problems by concenating the Strings I need for the javaScript in the Bean and using the very important escapeXml="false" parameter.

You can escape quotation-mark characters, though it's probably going to be easier simply to use a <cut> tag only to print your dynamic data -- and simply keep your static data in template text.
Hope that helps; please let me know if you have any followup questions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic