Is it something you could solve with JSP custom taglibs?
Notice that it is quite easy to intermix JSPs with Servlets.
Just in case you don't know them, here are is a good introduction from Sun:
http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html
and some Apache starting pointers:
I'm looking for a solution where I can insert code into pages (like applet
tags into html, etc...) already served up by the server (and not know
anything about the pages themselves). This seems to be do-able in 2.3
servlet specs w/ filters, but as I'm running into several undocumented
issues with