title: How to pass values from servlet to html page
body: <p>I'm developing a web server using servlet (v3.0) and jetty v9. I have to serve a HTML page but before I do, I need to modify the CSS inline-styles for a couple of elements on the page, dependent on the value of a boolean variable.</p>
  
  <p>I've been looking at JSP tutorials and examples for ages, and I don't feel like I'm any closer to figuring it out. To simplify it, this is what I'm trying to do:</p>
  
  <p><strong>page.jsp: (in /WAR/html)</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;My Page&lt;/head&gt;
      &lt;body&gt;
          &lt;p &lt;% style="display:none" if variable is true %&gt;&gt;&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>GetPage.java:</strong></p>
  
  <pre><code>public class GetPage extends HttpServlet {
      public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
          boolean decision = getDecision();
          // get the JSP page and process the JSP with the boolean variable...
          resp.setContentType("text/html");
          resp.getWriter().print(???);
      }
  }
  </code></pre>
  
  <p>I've been using Java for years but never used JSP before. I would have thought this is JSP 101 but I don't understand how it works. Also, my real use case is not too far off that example above. Is JSP overkill for this purpose and if so, is there a better alternative?</p>