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.
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:
page.jsp: (in /WAR/html)
<html>
<head>My Page</head>
<body>
<p <% style="display:none" if variable is true %>></p>
</body>
</html>
GetPage.java:
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(???);
}
}
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?