In JSP:
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<% String str = "<abc & ' \">"; %>
<html>
<body>
<p>Escaped string: <%= fn:escapeXml(str) %> </p>
</body>
</html>
This requires the JSTL 1.2 JAR, which can be downloaded at https://mvnrepository.com/artifact/javax.servlet/jstl/1.2
Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts
Sunday, September 10, 2017
Tuesday, August 8, 2017
TLD error: attribute items does not accept any expressions
If you just upgrade Servlet from 2.3 to 2.4 and after that you encounter this error:
According to TLD or attribute directive in tag file, attribute items does not accept any expressions.
It may be because that (Quoted from https://docs.oracle.com/cd/E19316-01/819-3669/bnajh/index.html):
Each JSP page has a default mode for EL expression evaluation. The default value varies depending on the version of the web application deployment descriptor. The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL expressions; this automatically provides the default that most applications want. The default mode for JSP pages delivered using a descriptor from Servlet 2.3 or before is to ignore EL expressions...
To quick-fix this issue caused by the upgrade from Servlet 2.3 to 2.4, we can simple add this configuration in web.xml to change the behavior of Servlet 2.4 to be backward compatible with Servlet 2.3:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
</jsp-config>
According to TLD or attribute directive in tag file, attribute items does not accept any expressions.
It may be because that (Quoted from https://docs.oracle.com/cd/E19316-01/819-3669/bnajh/index.html):
Each JSP page has a default mode for EL expression evaluation. The default value varies depending on the version of the web application deployment descriptor. The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL expressions; this automatically provides the default that most applications want. The default mode for JSP pages delivered using a descriptor from Servlet 2.3 or before is to ignore EL expressions...
To quick-fix this issue caused by the upgrade from Servlet 2.3 to 2.4, we can simple add this configuration in web.xml to change the behavior of Servlet 2.4 to be backward compatible with Servlet 2.3:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
</jsp-config>
Subscribe to:
Posts (Atom)