You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by og...@yahoo.com on 2004/10/29 20:05:11 UTC
JSTL converts ' to '
Hello,
I'm having some JSTL difficulties that I haven't encountered before.
I have a string with a single quote in it:
<c:set var="foo" value="Foo's Moos"/>
If I just print that out (c:out), JSTL converts the single quote to
' and my browser recognizes that and renders it as a single quote.
Good.
However, if I try using this variable in, say, this piece of
Javascript:
<script>
alert("<c:out value='${foo}'/>");
<script>
then this will not work - the problem is that JSTL does ' --> '
conversion, and Javascript doesn't like something in '. Most
likely it's the semi-column that bothers it.
So, I've been trying to figure out how to stop this taglib from doing '
--> ' conversion and I just cannot find a way to do this.
Is this at all possible?
If anyone has any other ideas for working around this problem, please
let me know.
Thanks,
Otis
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: JSTL converts ' to '
Posted by og...@yahoo.com.
Ah, thanks - I thought false was the default.
Otis
--- Kris Schneider <kr...@dotech.com> wrote:
> <script>
> alert("<c:out value='${foo}' escapeXml='false'/>");
> <script>
>
> Quoting ogjunk-taglib@yahoo.com:
>
> > Hello,
> >
> > I'm having some JSTL difficulties that I haven't encountered
> before.
> > I have a string with a single quote in it:
> >
> > <c:set var="foo" value="Foo's Moos"/>
> >
> > If I just print that out (c:out), JSTL converts the single quote to
> > ' and my browser recognizes that and renders it as a single
> quote.
> > Good.
> >
> > However, if I try using this variable in, say, this piece of
> > Javascript:
> > <script>
> > alert("<c:out value='${foo}'/>");
> > <script>
> >
> > then this will not work - the problem is that JSTL does ' -->
> '
> > conversion, and Javascript doesn't like something in '. Most
> > likely it's the semi-column that bothers it.
> >
> > So, I've been trying to figure out how to stop this taglib from
> doing '
> > --> ' conversion and I just cannot find a way to do this.
> >
> > Is this at all possible?
> >
> > If anyone has any other ideas for working around this problem,
> please
> > let me know.
> >
> > Thanks,
> > Otis
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> taglibs-user-help@jakarta.apache.org
> >
>
>
> --
> Kris Schneider <ma...@dotech.com>
> D.O.Tech <http://www.dotech.com/>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: JSTL converts ' to '
Posted by Kris Schneider <kr...@dotech.com>.
<script>
alert("<c:out value='${foo}' escapeXml='false'/>");
<script>
Quoting ogjunk-taglib@yahoo.com:
> Hello,
>
> I'm having some JSTL difficulties that I haven't encountered before.
> I have a string with a single quote in it:
>
> <c:set var="foo" value="Foo's Moos"/>
>
> If I just print that out (c:out), JSTL converts the single quote to
> ' and my browser recognizes that and renders it as a single quote.
> Good.
>
> However, if I try using this variable in, say, this piece of
> Javascript:
> <script>
> alert("<c:out value='${foo}'/>");
> <script>
>
> then this will not work - the problem is that JSTL does ' --> '
> conversion, and Javascript doesn't like something in '. Most
> likely it's the semi-column that bothers it.
>
> So, I've been trying to figure out how to stop this taglib from doing '
> --> ' conversion and I just cannot find a way to do this.
>
> Is this at all possible?
>
> If anyone has any other ideas for working around this problem, please
> let me know.
>
> Thanks,
> Otis
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: JSTL converts ' to '
Posted by Rahul P Akolkar <ak...@us.ibm.com>.
Don't escape XML in the JavaScript bit.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="foobar" value="Foo's Moos" />
<html>
<head><script language="JavaScript">alert("<c:out value='${foobar}'
escapeXml='false' />");</script></head>
<body bgcolor="white">
<c:out value="${foobar}" />
</body>
</html>
-Rahul