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;'))}

Rate Me:

Create Servlet Project as Module

You would have seen that many times we are writing out own servlet in Liferay portal to achieve some specific use case. In DXP, You can st...