A nice solution to what you are trying to achieve is to use the Transform
Tag-Library available at http://epesh.com/transformtags.jsp. This allows
you to include XSL transformations retrieving both the XML and XSL from a
variety of sources, including inline. Because the XSL is inline on the
page, you can use JSP scriptlets and tags.
An alternative method is to install Cocoon as a servlet filter.. when it's
used as a filter, it allows XML/XSL to be produced by any processor (static
file, servlet, JSP, XSP, PHP, etc).
This should solve your problem.
-Joe Walnes