Thursday, December 23, 2004

jsp.error.attribute.unterminated

I recently dealt with this error in some JSP code I was writing and did not see much information out there on a cause and solution so here is what I found out.

I had already tracked the problem down to some code that should have been correct:


<display:column property="<%=rsmd.getColumnName(i)%>" title="<%=rsmd.getColumnName(i)%>&nbsp;&nbsp;&nbsp;&nbsp;"
sortable="true" headerClass="sortable" maxLength="20"
/>

When I remove the after the <%=%>the rsmd.getColumnName(i), it works correctly but when I add any other characters inside of the title value it fails.

The Problem: With the displaytag tablib you can not dynamically create strings from jsp and text inside of a key-value pair. You can place just JSP or just text inside the value but not the combination of both.
The Solution: Create a temporary String variable to hold the value you would like to place in the value pair and then only reference that string.

<% String columnTitle = rsmd.getColumnName(i) + "&nbsp;&nbsp;&nbsp;&nbsp;";%>


<display:column property="<%=rsmd.getColumnName(i)%>" title="<%=columnTitle%>"
sortable="true" headerClass="sortable" maxLength="20"
/>


Hope this helps someone else,
Richard

 

1 Comments:

Chris said...

Hi Richard. This has helped tremendously.

Thanks!

11:51 AM  

Post a Comment

<< Home