title: Execute JSP directly from Java
body: <p>I need to execute a JSP. But I need to directly from Java, without using Tomcat or any other servlet container. Compiling JSPs would be a good thing too, but not necessary. I think maybe org.apache.jasper package is good for doing this, but I can't find any good example or tutorial online.</p>
  
  <p>I need something as: </p>
  
  <pre><code>Class compiledJSP = compileJSP(new File("helloWorld.jsp"));
  String html = executeJSP(compiledJSP, httpServletRequest, httpServletResponse, ...);
  
  html --&gt; "Hello World, John!"
  </code></pre>
  
  <p>Thanks!</p>