JATO Tutorial

Chapter 1, Task 1

<< Prior Task | Top | Next Task >>

Task 1—Create the application infrastructure

Before developing any pages, we need to create the JATO application infrastructure. This is a one-time requirement for each JATO application.

Step 1: Create the application directories

  1. Create a working directory called JatoTutorial to contain all of our files. The structure under this directory will be a standard WAR file directory structure.
  2. /JatoTutorial
  3. Create the web documents directory.
  4. /JatoTutorial/jatotutorial/module1
  5. Create the WEB-INF directory.
  6. /JatoTutorial/WEB-INF
  7. Create the classes directory in the WEB-INF directory. You will create, edit, and compile your Java source code files in the classes directory.
  8. /JatoTutorial/WEB-INF/classes
  9. Create package directories in the classes directory
  10. /JatoTutorial/WEB-INF/classes/jatotutorial
    /JatoTutorial/WEB-INF/classes/jatotutorial/module1
  11. Copy the JATO tag library descriptor file from the JATO distribution into the application WEB-INF directory.
    /JatoTutorial/WEB-INF/jato.tld
  12. Create a lib directory in the WEB-INF directory.
  13. /JatoTutorial/WEB-INF/lib
  14. Copy the JATO jar file from the JATO distribution into the application lib directory.
  15. /JatoTutorial/WEB-INF/lib/jato-1_2.jar

Your directory structure should now appear as follows:

/JatoTutorial Main working directory
  /jatotutorial Document directory for jatotutorial application
    /module1 Document directory for module1 module (jsp files here)
  /WEB-INF Web application information
    jato.tld JATO tag library descriptor file
    /classes Application classes
      /jatotutorial Directory for jatotutorial package classes
        /module1 Directory for module1 package classes
    /lib Additional application classes (jar files)
      jato-1_2.jar JATO jar file

Step 2: Create the application servlet

  1. Copy the template file __appName__ServletBase.java from the /templates/1_2/ApplicationTemplates directory to your /WEB-INF/classes/jatotutorial directory. Be careful not to confuse your document directories with your Java package directories, as they have the same names.

    /JatoTutorial/WEB-INF/classes/jatotutorial/__appName__ServletBase.java

  2. Rename the file JatoTutorialServletBase.java
  3. Edit the file and replace the following tokens as indicated:
  4. Token Replacement Text
    __appPackage__ jatotutorial
    __appName__ JatoTutorial

Your code for JatoTutorialServletBase.java should now look like the following (note, this sample shows only the code affected by token replacement):

package jatotutorial;

import com.iplanet.jato.*;
import com.iplanet.jato.view.*;
import com.iplanet.jato.util.*;

public class JatoTutorialServletBase extends ApplicationServletBase
{

    public JatoTutorialServletBase()
    {
        super();
    }

    ...
}

Step 3: Create a ModelTypeMap

  1. Copy the template file ModelTypeMapImpl.java from the /templates/1_2/ApplicationTemplates directory to your /WEB-INF/classes/jatotutorial directory.

    /JatoTutorial/WEB-INF/classes/jatotutorial/ModelTypeMapImpl.java

  2. Edit the file and replace the following tokens as indicated:

    Token Replacement Text
    __appPackage__ jatotutorial

Note, this task will not make use of any application-specific Model classes; therefore you do not need to add any additional code to this class until instructed to do so.

Step 4: Create a SQLConnectionManager implementation

  1. Copy the template file SQLConnectionManagerImpl.java from the /templates/1_2/ApplicationTemplates directory to your /WEB-INF/classes/jatotutorial directory:

    /JatoTutorial/WEB-INF/classes/jatotutorial/SQLConnectionManagerImpl.java

  2. Edit the file and replace the following tokens as indicated:

    Token Replacement Text
    __appPackage__ jatotutorial

Note, this task will not make use of any application-specific JDBC connections; therefore you do not need to add any additional code to this class until instructed to do so.

Step 5: Create the module servlet

  1. Copy the template file __moduleName__Servlet.java from the /templates/1_2/ModuleTemplates directory to your /WEB-INF/classes/jatotutorial/module1 directory
  2. /JatoTutorial/WEB-INF/classes/jatotutorial/module1/__moduleName__Servlet.java
  3. Rename the file Module1Servlet.java
  4. Edit the file and replace the following tokens as indicated:

    Token Replacement Text
    __appPackage__ jatotutorial
    __appName__ JatoTutorial
    __modulePackage__ module1
    __moduleName__ Module1

Your code for Module1Servlet.java should now look like this (note, this sample shows only the code affected by token replacement):

package jatotutorial.module1;

import javax.servlet.*;
import javax.servlet.http.*;
import jatotutorial.*;
import com.iplanet.jato.*;
import com.iplanet.jato.util.*;
import com.iplanet.jato.view.*;

public class Module1Servlet extends JatoTutorialServletBase
{

    public Module1Servlet()
    {
        super();
    }

    ...

    public static final String DEFAULT_MODULE_URL="../module1";
    public static String PACKAGE_NAME=getPackageName(
        Module1Servlet.class.getName());
}

Step 6: Prepare the deployment descriptor

  1. Copy the template file web.xml from the /templates/1_2/ApplicationTemplates directory to your /WEB-INF directory.
  2. /WEB-INF/web.xml

  3. Edit the file and replace the following tokens as indicated:

    Token Replacement Text
    __appPackage__ jatotutorial
    __modulePackage__ module1
    __moduleName__ Module1

Your web.xml file should look like this:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN' 
    'http://java.sun.com/j2ee/dtds/web-app_2_2.dtd'>

<web-app>
    <context-param>
        <param-name>jato:jatotutorial.module1.*:moduleURL</param-name>
        <param-value>../module1</param-value>
    </context-param>
    <servlet>
        <servlet-name>Module1Servlet</servlet-name>
        <servlet-class>jatotutorial.module1.Module1Servlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Module1Servlet</servlet-name>
        <url-pattern>/module1/*</url-pattern>
    </servlet-mapping>
    <taglib>
        <taglib-uri>/WEB-INF/jato.tld</taglib-uri>
        <taglib-location>/WEB-INF/jato.tld</taglib-location>
    </taglib>
</web-app>

 

<< Prior Task | Top | Next Task >>