PDA

View Full Version : Tomcat 6.0.24 Duplicate Variable issue



nibertj
Mar 8th, 2010, 12:29 PM
Recently upgraded to Tomcat 6.0.24 (64 bit). Our application previously successfully ran on Tomcat 6.0.20 (using Spring 2.5) . After the Tomcat upgrade, jsp pages started to fail. After digging through the code (too many includes)- we finally determined that we had nested <spring:bind> tags. And this was causing the error. Re-factored the jsp pages to eliminate nested <spring:bind> tags - and the application kept working. Does anyone know why these nested tags worked in earlier versions of Tomcat and not in the 6.0.24 version?

Sample Code (Nested <spring:bind>):


<spring:bind path="publishForm.phoneNumber">
<c:out value="${status.value}" />
<c:if test="${ testValue != 0 }">
<spring:bind path="publishForm.phoneType">
<c:out value="${status.value}"/>
</spring:bind>
</c:if>
</spring:bind>

The fix was to make a pageScope variable and then do the if:

<spring:bind path="publishForm.phoneNumber">
<c:out value="${status.value}" />
<%--
Have to set a page scope because Tomcat 6.0.24 will not
permit nested spring:bind tags....This way we can still do
the if phone number has some value get its type call below.
--%>
<c:set var="testValue" scope="page" value="${status.value}"/>
</spring:bind>
<c:if test="${ testValue != 0 }">
<spring:bind path="publishForm..phoneType">
<c:out value="${status.value}"/>
</spring:bind>
</c:if>

Thanks.

firebrick72
Mar 8th, 2010, 04:05 PM
Just bumped into the same issue (;
Seems it is due to a restriction in the JSP 1.1 Specification that disallows
using the same value for an id attribute more than once in a single JSP page.

As a work-around, some people recommend using the following in web.xml if there is 2.4 as in my case:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
...
</webapp>
but I have not tried it yet.

firebrick72
Mar 8th, 2010, 05:31 PM
Seems the solution is 6.0.25 version. Tomcat 6.0.25 (http://people.apache.org/~jfclere/tomcat-6/v6.0.25/)
Checked - it works.