Programmers Guide > JOT Views for Servlets

JOT Views for Servlets

Any Java Servlet, including non JOT servlets and JSP pages, can invoke the JOT Views rendering engine to generate dynamic content.

Response Rendering:

A Java Servlet invokes the JOT Views serviceRequest() method to send a response to the web client. This renders dynamic content with a JOT Template and a JotResponseBean, as in this Servlet doGet() example:

    // Overrides javax.servlet.http.HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse rsp)
        throws ServletException, java.io.IOException
    {
        ... [some processing steps]...

        JotViews.serviceRequest(this, req, rsp, ExampleJotResponseBean.class);
    }

This technique provides non JOT servlets with dynamic content response rendering using JOT Web Components, JOT Templates, and JOT Iterators. This is not necessary for subclasses of JotHttpServlet that invoke the rendering engine automatically (see Quick Start, Step 2).

Component Rendering:

Java Servlets can invoke the JOT Views rendering engine with the renderComponent() method. This instantiates and prepares a JOT Web Component and renders dynamic content into the Servlet response stream, as in this servlet fragment:

    // Render dynamic content with a JotContentBean
    JotViews.renderComponent(this, req, rsp, ExampleJotTemplateBean.class);

This provides any Java Servlet with dynamic content response rendering using JOT Web Components, JOT Templates, and JOT Iterators.

© 2007 JOT Object Technologies