Programmers Guide > Deploying JOT Servlets

Deploying JOT Servlets

Zero configuration means no special XML configuration files are required for JOT Servlets. All JOT Servlets initialization parameters are optional with reasonable defaults. This section describes web.xml deployment descriptor initialization parameters, and alternative configuration mechanisms.

Servlet Class:

A JOT Servlet name is mapped either to a subclass of JotHttpServlet or to the generic JotMappedServlet as shown in these examples:

    <servlet-class>com.examples.FooBarServlet</servlet-class>

    <servlet-class>com.jotobjects.servlet.JotMappedServlet</servlet-class>

JotResponseBean Class:

The JotResponseBean class is determined dynamically at request time with the method getJotResponseBeanClass(). Default rules determine the name of the JotResponseBean class unless the JotHttpServlet subclass overrides getJotResponseBeanClass(). If the deployment descriptor specifies a JotResponseBeanClass servlet initialization parameter, the mapping is established as shown in this example:

    <init-param>
        <param-name>JotResponseBeanClass</param-name>
        <param-value>com.examples.FooResponseBean</param-value>
    </init-param>

JOT Template ContentSource:

A ContentSource must be defined for every JotServletTemplateBean. The ContentSource can be specified programmatically or set with the ContentSourceName servlet initialization parameter (see getContentRenderer()).

    <init-param>
        <param-name>FooResponseBean.ContentSourceName</param-name>
        <param-value>/templates/FooTemplate.html</param-value>
    </init-param>

The ContentSource for a component can be assigned dynamically before the component is rendered by setting the ContentRender property as is this example:

    <!-- Set the ContentSource -->
    JOT.MyComponent.ContentRenderer=("/webpages/mycomponent.html")

Or the template name can be specified with the Content token:

    <!-- Render component content -->
    JOT.MyComponent.Content("/webpages/mycomponent.html")

In the above examples the template name could be itself a dynamic parameter:

    <!-- Render component content -->
    JOT.MyComponent.Content(JOT.MyDynamicTemplateName)

A technique for embedded components is for the JOT Template file to be placed in the same directory as the JotServletTemplateBean class and deployed with the Servlet classes (in the JAR and WAR files). Then the ContentSource can be constructed using java.lang.Class getResource() as shown in this example:

    // Fragment of a JotServletTemplateBean...

    private static ContentSource templateSource = new URLContentSource(
        FooResponseBean.class.getResource("FooTemplate.html"));

    public void prepareJotBean()
        throws JotException
    {
        super.prepareJotBean();
        setContentRenderer(templateSource);
    }

    // other methods not shown...

The ContentSource can also be deployed in a String object, as in this JOT Web Component example:

    // Fragment of a JotServletTemplateBean...

    private static ContentSource templateSource = new StringContentSource(
        "<td>JOT.ProductName</td><td>JOT.ProductPrice</td>");

    public void prepareJotBean()
        throws JotException
    {
        super.prepareJotBean();
        setContentRenderer(templateSource);
    }

    // other methods not shown...
© 2007 JOT Object Technologies