2004-11-29

struts, scriptlets, html taglib and tomcat 4.03 linux

A strange error that I encountered when deploying a webapp to a tomcat 4.03 installation on linux. I feel compelled to post information about it in my weblog to help others who might encounter the same error:

org.apache.jasper.compiler.ParseException: /WEB-INF/pages/freightDetails.jsp(115,51) Attribute has no value

This was caused by a struts-html tag with a scriptlet:

<html:radio property="freightId" value="<%= "" + ((webstore.objects.FreightOption) opt).getId() %>"/>

OK, now I realize it is my own fault that I was being lazy and using "" + to turn the next item into a string... the problem disappeared when I used the following code:

<html:radio property="freightId" value="<%= (new Integer(((webstore.objects.FreightOption) opt).getId())).toString() %>"/>

The bug did not appear under tomcat 5.x on my OSX machine, as it appears to correctly interpret scriptlets in tags.

No comments: