Rendering JSP into dummy response to obtain HTML
843838May 31 2007 — edited Jun 1 2007Is it possible to render a JSP into a mock response?
A project I'm working on requires me to render a series of small JSPs that are currently being included into a parent JSP. I would like to be able to render each individually, and then store the resulting String from the response for later use. I don't want to actually affect the real httpservletresponse at this time, just obtain the String from the JSP, store it, and throw away the response.
Is there an api besides requestdispatcher.forward() and .include() that can be used?
I tried creating a simple implementation of httpservletresponse, but it actually crashed my tomcat when I tried to pass that to the requestdispatcher.
I'm thinking about trying the mocks provided by spring, but I'm not crazy about the idea of having 'test' code within a running application ( I guess you don't have to look at it that way though).
Someone please tell me if I'm trying to do something impossible here:)