【发布时间】:2010-11-07 17:32:06
【问题描述】:
我需要执行一个 JSP。但我需要直接从 Java 中获取,而不使用 Tomcat 或任何其他 servlet 容器。编译 JSP 也是一件好事,但不是必须的。我认为也许 org.apache.jasper 包可以很好地做到这一点,但我在网上找不到任何好的示例或教程。
我需要一些东西:
Class compiledJSP = compileJSP(new File("helloWorld.jsp"));
String html = executeJSP(compiledJSP, httpServletRequest, httpServletResponse, ...);
html --> "Hello World, John!"
谢谢!
【问题讨论】:
-
但是为什么要这样做呢?您只想以编程方式生成 HTML 吗?
-
这之前被标记为 stackoverflow.com/questions/956112/… 或 stackoverflow.com/questions/8141813/… 的欺骗。不是。