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:
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.
<%@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" %>
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.../> ?