2 Replies Latest reply on Aug 3, 2007 11:48 AM by Sebastian Cramer

    Auto generating JSPs

    Sebastian Cramer Newbie

      Hello and cheers...

      Maybe I am suffering from some sort of severe brain-worms... But I have a problem with the JSPs:

      I have some content stored in a database. I would like to allow this content to include JSP tags (well - especially tags of one taglib). This content can be included into a JSP page via a custom tag. The thing now is: how can I manage to treat the content from an external source (in my case a database) as JSP source code?
      It is not really feasible to use plain HTML...

      I'm afraid I'm just stuck and simply do not see the simple solution... Thanks for your help


        • 1. Re: Auto generating JSPs
          Peter Johnson Master

          The problem is that by the time the code in the JSP runs, and this includes the code in the tag that is getting the 'code' out of the database, the JSP has already been compiled. So there is no way to include that 'code' in the JSP.

          However, I assume that the 'code' eventually generates HTML to include in the page. Therefore, you could look into generating, and compiling, a class on the fly, using the 'code' as the body of a method that returns a string. Defining an interface that describes this method would help.

          • 2. Re: Auto generating JSPs
            Sebastian Cramer Newbie

            Instead of a JSP page I would also be able to use a servlet. The more I think about it - it all boils down to one question: How do I call the JSP compiler? I looked at the jasper docs - but I dont quite understand how to start... :-(
            The thing is I do need to use the taglib so it might be sensible to do the compiling myself - but then using the JSP compiler would be more flexible...