Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to manually invoke jsp servlet?

 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi-
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.

Is there any way to do this?

thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuck, why?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Makes me shiver just to think about it. What are you really trying to accomplish? Perhaps there's a cleanly supported way of doing it.
 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. I know. Sounds messy.

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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic