tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <ogjunk-tag...@yahoo.com>
Subject Mixing JSTL with scriptlet and problematic evaluation order
Date Mon, 13 Dec 2004 23:37:29 GMT
Hello,

I have a variable in the request context that I'm accessing with JSTL. 
The text value of the variable is used in a JavaScript call (at the
end).

The problem is that the text value contains an apostrophe (a single
quote).  Since single quotes are used in the JavaScript call, this
causes the open/close single quote mismatch.

So I need to find a way to encode the single quote somehow.  I could
not find a pure JSTL solution for this.  Is there a way to do this with
just JSTL?

Because I couldn't find a nice JSTL solution, I tried it with a mixture
of JSTL and the scriptlet:

...&title=' + '<%= URLEncoder.encode("<c:out value='${titleText}'/>",
"UTF-8") %>'

Guess what this results in?
Well, the scriptlet part must be getting interpreted first, so the
URLEncoder.encode gets that "<c:out value..." string literal as input,
instead of getting the output of c:out.  So that doesn't work either.

Here is a bit more of the JavaScript call in question:

onclick="javascript:window.open('Blah.do?sortId=<c:out
value="${sortId}"/>&......&title=' + '<%= URLEncoder.encode("<c:out
value='${titleText}'/>", "UTF-8") %>', 'Foobar'....


Has anyone run into this problem before and knows a solution?  I pure
JSTL solution would be great, but I'll go for a hack this time if I
have to (Oh how I hate that!).

Thanks,
Otis



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message