tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: Quoting problem
Date Tue, 06 Aug 2002 13:45:54 GMT
On Tue, 6 Aug 2002 Eric.Lewis@swissinfo.ch wrote:

> I'm trying only to write a link's target if it actually exists or is
> different than "_self". This is my code:
> 
> <%-- Save the link target window if necessary --%>
> <c:choose>
>   <c:when test="${(link.target == null) || (link.target == '') ||
> (link.target == '_self')}">
>     <c:set var="target" value=""/>
>   </c:when>
>   <c:otherwise>
>     <c:set var="target" value=' target="${link.target}"'/>
>   </c:otherwise>
> </c:choose>
> 
> Unfortunately, in my link below which reads
> <a href="<c:out value="${link.url}"/>"<c:out value="${target}"/>>
> 
> I get the following result when the page is created:
> <a href="http://mp3.swissinfo.org" target=&#034;_blank&#034;>
> 
> How can this be escaped when I don't use escapeXml?

Why not use escapeXml?  Your intent is to print XML metacharacters (the
quotation mark has special syntactic meaning to XML), so it seems to make
sense to set escapeXml="false" in the latter "target" tag.

The other option, in this specific case, is to make "target" more
specific.  Does the browser behave the way you want it to behave it a tag
looks like

  <a href="http://foo" target="">

If so, then you could set the 'target' variable only to the *value* of the
'target' attribute and then write

  target="<c:out value="${target}" />"

Hope that helps,

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


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


Mime
View raw message