In this example, we create a tag that can be used to escape user-inputted values for display on the next page.
escape.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>
calls StringEscapeUtils.escapeHtml for value
</description>
<tlib-version>1.0</tlib-version>
<short-name>escape</short-name>
<uri>escape</uri>
<function>
<name>esc</name>
<function-class>org.apache.commons.lang.StringEscapeUtils</function-class>
<function-signature>
java.lang.String escapeHtml( java.lang.String )
</function-signature>
</function>
</taglib>
In the JSP page
<%@ taglib uri="escape" prefix="es" %>
${es:esc(param.home)}
No comments:
Post a Comment