tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Haszlakiewicz <>
Subject Re: URL-escape a var with JSTL
Date Thu, 02 Mar 2006 04:46:00 GMT
> wrote:
> >Hello,
> >I need to URL-escape a variable in JSTL, and am not having much luck 
> >finding the way to do it.
> >
> >For example, I currently do:
> ><c:set var="foo" param="${}"/>
> >
> >Since "foo" param may include some funky characters, I need to URL-escape 
> >that.  So I'm looking for something similar to:
> >
> ><c:set var="foo" param="${}" escapeXml="true"/>

<c:set var="foo"><c:out value="${}"></c:set>
<c:set var="foo" value="${fn:escapeXml(}"/>

However, that's encoded with HTML/XML character entities, NOT url encoding.
    input value  |   c:out   |    url encoding
    "foo bar"      "foo bar"      "foo+bar"
    "A&B"        | "A&amp;B" |    "A%26B"

> >What's the right way to URL-encode a variable with JSTL, without resorting 
> >to scriptlets?

	Note that URLEncoder.encode() is a static method, so if you really
do mean "url encode" you could write a short tld to allow you to access
it as an EL function.  Or, you could use the jakarta String TagLib, which
has a encodeUrl tag:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message