• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamically Creating JSP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say you get some data from a source and you use this data and create a jsp page from it (Does not matter what data etc, you jsut use some form of data to create some jsp page). You can have this page in stream or file format.

I would be using struts.

Would it be possible to create this stream/file while in the same web container then display it?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure. Have a servlet that will write the text of the JSP out to a file then forward to it. The engine will detect that it hasn't yet been translated and trigger the translation. Seems like a really weird thing to do, but possible.
 
Brian Leblanc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I'm creating a preview for another page on the fly. I will have a process that converts the xml I get to a valid jsp page that will use my custom tag defeintions.

I have two routes, I can have my servelts read it as a jsp, or convert it to html manually (populate the object that my custom tags expect to generate the xml).

The problem I see with writing as a JSP is a possible threading issue.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another alternative would be to write the code for the dynamic page in a scripting language such as Jython or Groovy.
Your custom tags would have to be re-implemented of course.
Bill
 
Brian Leblanc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I am using this creaeted file to render, then delete it on session end, would I have a problem with the class loader at all?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by William Brogden:
Another alternative would be to write the code for the dynamic page in a scripting language such as Jython or Groovy.
Your custom tags would have to be re-implemented of course.
Bill



Just curious, why would this be a good idea in comparison to what Bear suggested? I am still trying to see the benefit of scripting languages meshed with Java.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Just curious, why would this be a good idea in comparison to what Bear suggested?


What bothers me about writing a new JSP file every time a request is processed is that you end up with all these .jsp and .class files cluttering up the disk, and loaded class files cluttering up memory.
Seems to me you end up with a housekeeping problem.

I am still trying to see the benefit of scripting languages meshed with Java.


Me too so far I have not found many but so many folks are enthusiastic about scripting languages I feel I should make an effort!
Bill
 
Brian Leblanc
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I was thinking of having the files naems based off the session ID for physical cleanup. The problem I run into is how to remove it from memory..

Would it be possible to use a custom ClassLoader? This is one area where I really have no expertise.

I'd like to avoid this but I don't know another way that I could render a jsp file from a String. Thats the main goal.. I get a String that is an entire jsp file (with custom tags) from an object and I need to render it.. in the same container.
reply
    Bookmark Topic Watch Topic
  • New Topic