Do not redefine a taglib prefix using a different URI

This rule flags JSP taglib directives which associate the same prefix attribute value with different uri attribute values. The redefinition will be flagged if it occurs within the same JSP file or if it occurs within a statically included JSP file or fragment.

In accordance to JSP 2.1 specifications, a prefix should not be redefined within the current scope of the JSP. If a tag library prefix is already defined with a different URI within a JSP or in an included JSP or fragment, the product must create a translation error. JSP 2.1 was new in WebSphere Application Server V7. The validation is new to that release and was not enforced in prior versions.

The best-practices solution is to change the taglib directive to use unique prefixes and to update the affected JSP file to use the new prefix.

If you do not want to change the JSP files, you can reverse this behavior for the web module to that of previous versions by setting the following JSP attribute in the IBM web extension file ( ibm-web-ext.xml ):

<jsp-attribute name="allowTaglibPrefixRedefinition" value="true"/>

Alternatively, you can set a web container custom property com.ibm.wsspi.jsp.allowtaglibprefixredefinition=true to affect all applications on the server rather than just the particular web module that the first option offers.

Example 1: Given the following lines are in the same JSP file called Page1.jsp
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/otherLib.tld" prefix="fmt"%>

In Example 1, the second entry will be flagged because it is a redefinition of fmt . For this example, the tool will log the following warning message in the Eclipse error log:

!MESSAGE CWMIG1125W: The WebContent/Page1.jsp file attempted to redefine the URI value for the fmt prefix from /WEB-INF/fmt.tld to /WEB-INF/otherLib.tld.
The Do not redefine a taglib prefix using a different URI rule encountered the problem while analyzing the /MyJspProject/WebContent/Page1.jsp file in the MyJspProject project.

Example 2: Given a JSP file, called Page2.jsp with the following content:
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@ include file="myPage.jspf"%>

where myPage.jspf contains the line

<%@ taglib uri="/WEB-INF/otherLib.tld" prefix="fmt"%>

In Example 2, the taglib line in myPage.jspf will get flagged. In this example, you will see the following warning logged in the Eclipse error log:

!MESSAGE CWMIG1124W: The WebContent/myPage.jspf file attempted to redefine the URI value for the fmt prefix from /WEB-INF/fmt.tld to /WEB-INF/otherLib.tld in the scope of the WebContent/Page2.jsp file.
The Do not redefine a taglib prefix using a different URI rule encountered the problem while analyzing the /MyJspProject/WebContent/Page2.jsp file in the MyJspProject project.

Use the error log information to help figure out the conflicting files. An included JSP file can cause redefinitions with multiple base JSP files in different scopes. In this case, a file might be flagged multiple times where a single fix will clear up multiple problems. It is possible that the same included file could redefine the tag library URI differently depending on which JSP file includes it. For this reason, each error is listed.

To open the Eclipse error log, click Window > Show view > Other > Error log .

For additional information, see: