Re: JSTL <c:out> tag-- how to escape apostrophe

Kris Schneider <[email protected]>
Newsgroups gmane.comp.jakarta.taglibs.user
Message-ID <[email protected]>
Quoting Chandra Avutu <[email protected]>:

> I am using JSTL c:out tag to print server messages into HTML pages. However
> some of the messages contains apostrophe. Due to special chars the JSTL
> c:out
> tag was breaking. The following message from server breaks <c:out> tag.
> "Invalid datastore path 'No_Floppy.flp'." Is there any was I can fix this.
> Thanks, Chandra

I'm not sure why this isn't working for you, but here's an example to
demonstrate that escaping should be taking place. Try this page:

<%@ page contentType="text/plain" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="chars">& < > " '</c:set>
Escaped chars: <c:out value="${chars}"/>
Unescaped chars: <c:out value="${chars}" escapeXml="false"/>

The output should look like:

Escaped chars: &amp; &lt; &gt; &#034; &#039;
Unescaped chars: & < > " '

-- 
Kris Schneider <mailto:[email protected]>
D.O.Tech       <http://www.dotech.com/>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.