Right, I understand. Yes, writing direct to the JspWriter like that isn't going to work.
As of JSP 2.0 you can implement a custom tag in a .tag file. This is a far more expressive way of doing things like this (the difference between tag classes and tag files is analogous to the difference between servlets and JSPs). Google will throw up plenty of examples, but this is the sort of thing I mean:
Code:
<%@tag body-content="empty"%>
<%@attribute name="labelText" required="false" type="java.lang.String"%>
<%@attribute name="bindPath" required="true" type="java.lang.String"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<spring:bind path="${bindPath}">
<label for="${status.expression}">${labelText}</label>
<input type="text"
id="${status.expression}"
name="${status.expression}"
value="${status.displayValue}"/>
</spring:bind>
This writes out a simple text input field using the traditional spring:bind tags, rather than the newer html:form tags, but the principal is the same.
JSP 2.0 is pretty mainstream now, so I'd be surprised if you weren't on it - what container are you using?
Even if you're stuck with your current approach, I'd think that <jsp:include.../> was preferable to <c:import.../> ?