link to table of contentsgo to previous topicgo to next topiclink to glossaryindex of terms


Using JSPTemplate Actors

AppComposer uses an actor called a JSPTemplate to handle communication between a servlet capsule and a JSP or HTML file.

The JSPTemplate actor links the servlet to the correct JSP file and handles the passing of parameters and method calls back and forth between the JSP and the servlet capsule. The only thing you have to define in order for the actor to handle the communication is the path from the capsule to the JSP.

To add a JSPTemplate actor:

  1. From the Palette window, select Html -> JSPTemplate.
    You may have to scroll down to the bottom of the list to see this selection
  2. Rename the JSPTemplate MathTablePage.

You need to link this servlet to the mathtable.jsp file in the Math.zap project. To do so, you need to edit the properties of the MathTablePage actor.

To link MathTablePage to mathtable.jsp:

  1. Select MathTablePage in the outline.
  2. In the Details pane, type the path and file name of the template relative to the project.
  3. If you wish, you can add a comment describing the actor.

    In this simple project, the JSP file is at the "root" of the project. If you create a project with several directories or with a directory and subdirectories, you would need to include the relative path from the project's "root" to the JSP resource file when you define the JSPTemplate's path property.

To add the ability to respond to a browser:

  1. Insert a ServletGet behavior as a child of MathTablePage.
    Insert -> Saved Group -> ServletGet
  2. In the Details pane, change the activation event from servlet.response.doGet to servlet.response.doPost.

  3. In the Outline, rename ServletGet to ServletPost.

Now the MathTablePage actor is set up to act as liaison between the servlet and the JSP. When the servlet gets a POST request, it will process and send the JSP file. Before you can construct behaviors to carry out any calculations, you need to add some variables and actors that allow you to do numeric processing. The next topic introduces you to NumberParser and NumberFormatter, which make it easy to convert text to numbers, and numbers to text, when necessary.

link to table of contentsgo to previous topicgo to next topiclink to glossaryindex of terms
      © 2003 DigiSlice Corporation