Encoding text for special XML characters

You may find it advantageous to use JSTL to encode XML characters for XDIME content

XDIME content must be in the form of valid XML. Portlets displaying dynamic text, such as data from a database or input from the user, need to handle the possibility that the text could include special XML characters. If the XML characters are not properly escaped, Mobile Portal Accelerator will not be able to properly render the content.

One option for handling special XML characters is use the JSTL <c:out> tag to display all dynamic strings. The JSTL <c:out> tag performs XML character-entity encoding for <, >, &, ", and '. For example, a string containing a < symbol will be automatically encoded to < when displayed by the <c:out> tag. This capability is controlled by the escapeXml attribute, and it defaults to true.

To use the tag, you need this directive in your JSP:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Then wrap your output in a <c:out> tag similar to the following:
First name: <c:out value="${Employee.Ename}" />



Terms of use
(C) Copyright IBM Corporation 2012. All Rights Reserved.