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 JotServlet as shown in these examples:

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

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

JotResponseBean Class:

The default JotResponseBean class for a JotServlet is com.jotobjects.servlet.JotResponseBean. In general the JotResponseBean class is determined dynamically at request time by the method getJotResponseBeanClass(). The deployment descriptor can specify the mapping with the JotResponseBeanClass servlet initialization parameter 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 template name can be specified with the Content token that renders the component as in this example:

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

Or the Renderable content can be assigned to a property:

    <!-- Assign component to a property -->
    JOT.MyRenderable=(JOT.MyComponent.Content("/webpages/mycomponent.html"))

Or the ContentSource can be specified with the JOT.Views.Component token that creates the component:

    <!-- Assign component to a property -->
    JOT.MyRenderable=(JOT.Views.Component(
        com.examples.MyComponent,("/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 template = new URLContentSource(
        FooResponseBean.class.getResource("FooTemplate.html"));
    private static ContentRenderer renderer = new JotTemplateRenderer(template);

    public void prepareJotBean()
        throws JotException
    {
        setContentRenderer(renderer);
    }

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
    {
        setContentRenderer(templateSource);
    }
© 2008 JOT Object Technologies