I would like to generate JSP source code on-the-fly. Is there any way I can pass this source dynamically to the jsp servlet using the spec? Rather than forwarding/including a request through requestdispatcher that loads the jsp source from the filesystem.
It's hard to explain. Basically, I'll be piecing together bits of content and model data from various sources in a servlet (most likely a Spring controller, if that makes any difference) into an xhtml document. That resulting document may contain JSP code that needs to be executed after it's cobbled together.
I checked out the implementation of apache's jasper servlet (org.apache.jasper.servlet.JspServlet). Looks like the streaming, compilation, and processing of the jsp page is left up to each vendor, done in the service() method. So - there's doesn't seem way to uniformly pipe in jsp code and have it compile & execute.
I *may* be able to whittle the requirement down to not support scriptlets, and only process XML jsp tags and other JSTL tags. Is there a way i could parse the document, and kick off each tag as i bit it? But i guess there would be all kind of contexts that I would not have available.
I still don't understand the part of the requirement that requires you to dynamically generate and evaluate JSP.
Not that this is completely relevant, but in 10 years of writing Java-based web applications, including ones with *very* demanding client-side requirements, I've *never*, ever had to do this--it strikes me as very unlikely (but possible, I suppose) that what you're proposing is necessary (and it's *certainly* not good).
Without a simple use-case, however, it's impossible to know what to suggest as an alternative. But I just don't see it.
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad: