This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSTL: 2 questions: no string concenating? no escaping characters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL: 2 questions: no string concenating? no escaping characters?" Watch "JSTL: 2 questions: no string concenating? no escaping characters?" New topic
Author

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

Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
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

Joined: May 06, 2002
Posts: 160
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.


Shawn Bayern<br />"JSTL in Action" <a href="http://www.jstlbook.com" target="_blank" rel="nofollow">http://www.jstlbook.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL: 2 questions: no string concenating? no escaping characters?
 
Similar Threads
passed....just now!
Tomcat installation
q on JSTL
good old class diagrams
Are We doing wrong (IBM free Vouchers)