in mdresourcedecorator/src/main/java/org/apache/sling/mdresource/impl/HtmlServlet.java [76:129]
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
final SlingJakartaHttpServletRequest request = (SlingJakartaHttpServletRequest) req;
resp.setContentType("text/html");
resp.setCharacterEncoding("UTF-8");
final PrintWriter pw = resp.getWriter();
pw.println("<html>");
pw.println(" <head>");
final ValueMap props = request.getResource().getValueMap();
String title = props.get("jcr:title", String.class);
if ( title == null ) {
title = props.get("title", String.class);
}
if (title != null) {
pw.print(" <title>");
pw.print(Encode.forHtmlContent(title));
pw.println("</title>");
}
if (this.cfg.head_contents() != null) {
pw.println(this.cfg.head_contents());
}
pw.println(" </head>");
pw.println(" <body>");
pw.println(" <header>");
if (this.cfg.header_resource() != null) {
request.getRequestDispatcher(this.cfg.header_resource()).include(request, resp);
}
pw.println(" </header>");
pw.println(" <main>");
final Object html = props.get(this.cfg.html_elements_property());
if (html instanceof String) {
pw.println(html.toString());
} else if (html instanceof List) {
boolean startSection = true;
for (final Map.Entry<String, String> element : (List<Map.Entry<String,String>>) html) {
if (startSection) {
pw.println(" <div class=\"section\">");
startSection = false;
}
pw.print(element.getValue());
}
if (!startSection) {
pw.println(" </div>");
}
}
pw.println(" </main>");
pw.println(" <footer>");
if (this.cfg.footer_resource() != null) {
request.getRequestDispatcher(this.cfg.footer_resource()).include(request, resp);
}
pw.println(" </footer>");
pw.println(" </body>");
pw.println("</html>");
}