Forget about having two separate comma-separated strings.
Use a List<Heading>
, where Heading
is a bean containing a title
property and a tooltip
property.
Your JSP code is now straightforward, and doesn't need to parse a comma-seperated String into a list of tokens:
<c:forEach items="${headings}" var="heading">
<th title="<c:out value='${heading.tooltip}'/>">
<c:out value="${heading.title}" />
</th>
</c:forEach>
Java is an OO language. Use objects.