How can I intercept the output of the JSP engine (before it is delivered to the client), so that I can manipulate it before sending it to the connecting client?
As a design principle in JSP 1.1/Servlet 2.2, there is not a way to do this.
There is a way to do a version of this manipulation, however, using a custom tag library. You can wrap a custom tag around your entire JSP, and then your custom tag can view what was generated by the JSP code and perform any manipulations it wants before sending something on to the browser. Your JSP page might look something like this:
<%@ taglib uri="mytaglib.tld" prefix="custom" %> <custom:manipulate> My existing JSP. <% int i = 0; %> <%=i%> Done. </custom:manipulate>