• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to manually invoke jsp servlet?

 
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuck, why?
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
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.
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic