Reputation: 20307
I would like to compile and interpret JSP in Java, out of Tomcat or any other servlet container. I think I may use the Jasper libraries coming with Tomcat, but I can't find any example of how to do it on the Web.
The minimum I need is a function that returns an String (HTML resulting text) from a compiled JSP and a HttpServletRequest, or something similar.
Thanks.
Upvotes: 2
Views: 4542
Reputation: 37007
Uncle Bob's got some blog posts on how to use jasper outside of tomcat.
His conclusion:
The technique described here can be used to test virtually any static web page, or portion thereof outside of a container, and without a webserver running. It is relatively simple to set up; and then very easy to extend. With it, you can spin around the edit/compile/test loop very quickly, and can easily follow the rules of Test Driven Development.
Upvotes: 0
Reputation: 35246
If you're just looking for a text processor (not necessarily JSPs) , you can also have a look at Apache Velocity
Upvotes: 2
Reputation: 346270
interpret JSP in Java, out of Tomcat or any other servlet container.
That's simply not possible. Whatever you end up doing is going to be a reasonably complete implementation of a servlet container by the time it works on non-trivial JSPs (what about sessions? Application attributes? Taglibs?) anyway, so why not use one and save yourself the work of implementing it?
What is it that you actually want to achieve?
Upvotes: 1
Reputation: 8582
Have a look at the source code of ant task that comes with tomcat for pre-compiling jsp's. This should help you.
http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html
I'd also strongly question why you want to do this...
Upvotes: 0