Tomcat JSP/JSTL without HTTP

前端 未结 2 2007
南笙
南笙 2021-01-05 18:02

I have a pretty standard web app running under Tomcat 7.

What I\'m now trying to do is leverage JSP/JSTL as a templating language independent of the HTTP/web serving

2条回答
  •  一生所求
    2021-01-05 18:36

    This doesn't really make sense. A JSP is some nice syntax that results in the generation of a Java EE servlet class. Indeed, the "servlet" / "http" nature of a JSP is thoroughly intertwined through the APIs and the semantic model of JSPs and JSTL.

    If you want to generate HTML independently of web requests, you would be better of using a different templating technology; e.g. Velocity or FreeMarker. If you then want the HTML to be delivered as web responses as well, arrange that your servlets call the templating engine to generate responses. (If you are using Spring there is existing infrastructure for this. Other frameworks may have similar support, but if not, it shouldn't be hard to implement some glue code yourself to do this.)

提交回复
热议问题