17 October, 2014

Escape HTML using JSTL

Hello Friends,

If you are using JSTL to display HTML data in your application then you can escape HTML 2 ways in JSTL:

1) Using <c:out> tag
<c:out value="${specialCharString or HTML}" escapeXml="true"/>

2) Using EL Function

${fn:escapeXml("<i> This is jignesh vachhani")} 

Hope this will be useful somewhere.

If you want to use Liferay API then you can simply use

HTMLUtil.escape(String HTMLString)


Show/Display HTML tag in jsp

${fn:escapeXml(fn:replace(fn:replace(fn:replace("<div><p>This is jignesh testing</p></div>",'"','&quot;'),'<','&lt;'),'>','&gt;'))}

Popular Posts

Featured Post

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...